1// Copyright (c) 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_TEST_CHROMEDRIVER_ELEMENT_UTIL_H_
6#define CHROME_TEST_CHROMEDRIVER_ELEMENT_UTIL_H_
7
8#include <string>
9
10#include "base/memory/scoped_ptr.h"
11#include "chrome/test/chromedriver/basic_types.h"
12
13namespace base {
14class DictionaryValue;
15class ListValue;
16class Value;
17}
18
19struct Session;
20class Status;
21class WebView;
22
23base::DictionaryValue* CreateElement(const std::string& element_id);
24
25base::Value* CreateValueFrom(const WebPoint& point);
26
27// |root_element_id| could be null when no root element is given.
28Status FindElement(
29    int interval_ms,
30    bool only_one,
31    const std::string* root_element_id,
32    Session* session,
33    WebView* web_view,
34    const base::DictionaryValue& params,
35    scoped_ptr<base::Value>* value);
36
37Status GetActiveElement(
38    Session* session,
39    WebView* web_view,
40    scoped_ptr<base::Value>* value);
41
42Status IsElementFocused(
43    Session* session,
44    WebView* web_view,
45    const std::string& element_id,
46    bool* is_focused);
47
48Status GetElementAttribute(
49    Session* session,
50    WebView* web_view,
51    const std::string& element_id,
52    const std::string& attribute_name,
53    scoped_ptr<base::Value>* value);
54
55Status IsElementAttributeEqualToIgnoreCase(
56    Session* session,
57    WebView* web_view,
58    const std::string& element_id,
59    const std::string& attribute_name,
60    const std::string& attribute_value,
61    bool* is_equal);
62
63Status GetElementClickableLocation(
64    Session* session,
65    WebView* web_view,
66    const std::string& element_id,
67    WebPoint* location);
68
69Status GetElementEffectiveStyle(
70    Session* session,
71    WebView* web_view,
72    const std::string& element_id,
73    const std::string& property_name,
74    std::string* property_value);
75
76Status GetElementRegion(
77    Session* session,
78    WebView* web_view,
79    const std::string& element_id,
80    WebRect* rect);
81
82Status GetElementTagName(
83    Session* session,
84    WebView* web_view,
85    const std::string& element_id,
86    std::string* name);
87
88Status GetElementSize(
89    Session* session,
90    WebView* web_view,
91    const std::string& element_id,
92    WebSize* size);
93
94Status IsElementDisplayed(
95    Session* session,
96    WebView* web_view,
97    const std::string& element_id,
98    bool ignore_opacity,
99    bool* is_displayed);
100
101Status IsElementEnabled(
102    Session* session,
103    WebView* web_view,
104    const std::string& element_id,
105    bool* is_enabled);
106
107Status IsOptionElementSelected(
108    Session* session,
109    WebView* web_view,
110    const std::string& element_id,
111    bool* is_selected);
112
113Status IsOptionElementTogglable(
114    Session* session,
115    WebView* web_view,
116    const std::string& element_id,
117    bool* is_togglable);
118
119Status SetOptionElementSelected(
120    Session* session,
121    WebView* web_view,
122    const std::string& element_id,
123    bool selected);
124
125Status ToggleOptionElement(
126    Session* session,
127    WebView* web_view,
128    const std::string& element_id);
129
130Status ScrollElementIntoView(
131    Session* session,
132    WebView* web_view,
133    const std::string& element_id,
134    WebPoint* location);
135
136// |element_id| refers to the element which is to be scrolled into view.
137// |clickable_element_id| refers to the element needing clickable verification.
138// They are usually the same, but can be different. This is useful when an image
139// uses map/area. The image is scrolled, but check clickable against the area.
140// If |clickable_element_id| is "", no verification will be performed.
141Status ScrollElementRegionIntoView(
142    Session* session,
143    WebView* web_view,
144    const std::string& element_id,
145    const WebRect& region,
146    bool center,
147    const std::string& clickable_element_id,
148    WebPoint* location);
149
150#endif  // CHROME_TEST_CHROMEDRIVER_ELEMENT_UTIL_H_
151