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 13 namespace base { 14 class DictionaryValue; 15 class ListValue; 16 class Value; 17 } 18 19 struct Session; 20 class Status; 21 class WebView; 22 23 base::DictionaryValue* CreateElement(const std::string& element_id); 24 25 base::Value* CreateValueFrom(const WebPoint& point); 26 27 // |root_element_id| could be null when no root element is given. 28 Status 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 37 Status GetActiveElement( 38 Session* session, 39 WebView* web_view, 40 scoped_ptr<base::Value>* value); 41 42 Status IsElementFocused( 43 Session* session, 44 WebView* web_view, 45 const std::string& element_id, 46 bool* is_focused); 47 48 Status 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 55 Status 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 63 Status GetElementClickableLocation( 64 Session* session, 65 WebView* web_view, 66 const std::string& element_id, 67 WebPoint* location); 68 69 Status 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 76 Status GetElementRegion( 77 Session* session, 78 WebView* web_view, 79 const std::string& element_id, 80 WebRect* rect); 81 82 Status GetElementTagName( 83 Session* session, 84 WebView* web_view, 85 const std::string& element_id, 86 std::string* name); 87 88 Status GetElementSize( 89 Session* session, 90 WebView* web_view, 91 const std::string& element_id, 92 WebSize* size); 93 94 Status IsElementDisplayed( 95 Session* session, 96 WebView* web_view, 97 const std::string& element_id, 98 bool ignore_opacity, 99 bool* is_displayed); 100 101 Status IsElementEnabled( 102 Session* session, 103 WebView* web_view, 104 const std::string& element_id, 105 bool* is_enabled); 106 107 Status IsOptionElementSelected( 108 Session* session, 109 WebView* web_view, 110 const std::string& element_id, 111 bool* is_selected); 112 113 Status IsOptionElementTogglable( 114 Session* session, 115 WebView* web_view, 116 const std::string& element_id, 117 bool* is_togglable); 118 119 Status SetOptionElementSelected( 120 Session* session, 121 WebView* web_view, 122 const std::string& element_id, 123 bool selected); 124 125 Status ToggleOptionElement( 126 Session* session, 127 WebView* web_view, 128 const std::string& element_id); 129 130 Status 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. 141 Status 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