Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: chrome/test/automation/dom_element_proxy.cc

Issue 8584013: gtest / gmock shouldn't be in the shipping product (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert t_a_p change Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/automation/dom_element_proxy.h ('k') | chrome/test/automation/extension_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/automation/dom_element_proxy.h" 5 #include "chrome/test/automation/dom_element_proxy.h"
6 6
7 #include "chrome/test/automation/javascript_execution_controller.h" 7 #include "chrome/test/automation/javascript_execution_controller.h"
8 #include "chrome/test/automation/javascript_message_utils.h" 8 #include "chrome/test/automation/javascript_message_utils.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 9
11 using javascript_utils::JavaScriptPrintf; 10 using javascript_utils::JavaScriptPrintf;
12 11
13 // JavaScriptObjectProxy methods 12 // JavaScriptObjectProxy methods
14 JavaScriptObjectProxy::JavaScriptObjectProxy( 13 JavaScriptObjectProxy::JavaScriptObjectProxy(
15 JavaScriptExecutionController* executor, int handle) 14 JavaScriptExecutionController* executor, int handle)
16 : executor_(executor->AsWeakPtr()), handle_(handle) {} 15 : executor_(executor->AsWeakPtr()), handle_(handle) {}
17 16
18 JavaScriptObjectProxy::~JavaScriptObjectProxy() { 17 JavaScriptObjectProxy::~JavaScriptObjectProxy() {
19 if (is_valid()) 18 if (is_valid())
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 231 }
233 232
234 bool DOMElementProxy::GetName(std::string* name) { 233 bool DOMElementProxy::GetName(std::string* name) {
235 return GetAttribute("name", name); 234 return GetAttribute("name", name);
236 } 235 }
237 236
238 bool DOMElementProxy::GetVisibility(bool* visibility) { 237 bool DOMElementProxy::GetVisibility(bool* visibility) {
239 return GetValue("visibility", visibility); 238 return GetValue("visibility", visibility);
240 } 239 }
241 240
242 void DOMElementProxy::EnsureFindNoElements(const By& by) { 241 bool DOMElementProxy::DoesAttributeEventuallyMatch(
243 std::vector<DOMElementProxyRef> elements;
244 ASSERT_TRUE(FindElements(by, &elements));
245 ASSERT_EQ(0u, elements.size());
246 }
247
248 void DOMElementProxy::EnsureTextMatches(const std::string& expected_text) {
249 std::string text;
250 ASSERT_TRUE(GetText(&text));
251 ASSERT_EQ(expected_text, text);
252 }
253
254 void DOMElementProxy::EnsureInnerHTMLMatches(const std::string& expected_html) {
255 std::string html;
256 ASSERT_TRUE(GetInnerHTML(&html));
257 ASSERT_EQ(expected_html, html);
258 }
259
260 void DOMElementProxy::EnsureNameMatches(const std::string& expected_name) {
261 std::string name;
262 ASSERT_TRUE(GetName(&name));
263 ASSERT_EQ(expected_name, name);
264 }
265
266 void DOMElementProxy::EnsureVisibilityMatches(bool expected_visibility) {
267 bool visibility;
268 ASSERT_TRUE(GetVisibility(&visibility));
269 ASSERT_EQ(expected_visibility, visibility);
270 }
271
272 void DOMElementProxy::EnsureAttributeEventuallyMatches(
273 const std::string& attribute, const std::string& new_value) { 242 const std::string& attribute, const std::string& new_value) {
274 ASSERT_TRUE(is_valid());
275
276 const char* script = "domAutomation.waitForAttribute(" 243 const char* script = "domAutomation.waitForAttribute("
277 "domAutomation.getObject(%s), %s, %s," 244 "domAutomation.getObject(%s), %s, %s,"
278 "domAutomation.getCallId())"; 245 "domAutomation.getCallId())";
279 if (!executor_->ExecuteAsyncJavaScript( 246 return executor_->ExecuteAsyncJavaScript(
280 JavaScriptPrintf(script, this->handle(), attribute, new_value))) { 247 JavaScriptPrintf(script, this->handle(), attribute, new_value));
281 FAIL() << "Executing or parsing JavaScript failed";
282 }
283 } 248 }
284 249
285 template <typename T> 250 template <typename T>
286 bool DOMElementProxy::GetValue(const std::string& type, T* value) { 251 bool DOMElementProxy::GetValue(const std::string& type, T* value) {
287 if (!value) { 252 if (!value) {
288 NOTREACHED(); 253 NOTREACHED();
289 return false; 254 return false;
290 } 255 }
291 if (!is_valid()) 256 if (!is_valid())
292 return false; 257 return false;
293 258
294 const char* script = "domAutomation.getValue(" 259 const char* script = "domAutomation.getValue("
295 "domAutomation.getObject(%s), %s);"; 260 "domAutomation.getObject(%s), %s);";
296 return executor_->ExecuteJavaScriptAndGetReturn( 261 return executor_->ExecuteJavaScriptAndGetReturn(
297 JavaScriptPrintf(script, this->handle(), type), value); 262 JavaScriptPrintf(script, this->handle(), type), value);
298 } 263 }
OLDNEW
« no previous file with comments | « chrome/test/automation/dom_element_proxy.h ('k') | chrome/test/automation/extension_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698