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

Side by Side Diff: chrome/browser/geolocation/geolocation_browsertest.cc

Issue 10822030: Move ui_test_utils::RunMessageLoop to test_utils so that it can be reused by content_browsertests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 content::Source<NavigationController>(controller)); 55 content::Source<NavigationController>(controller));
56 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, 56 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE,
57 content::NotificationService::AllSources()); 57 content::NotificationService::AllSources());
58 std::string script = base::StringPrintf( 58 std::string script = base::StringPrintf(
59 "window.domAutomationController.setAutomationId(0);" 59 "window.domAutomationController.setAutomationId(0);"
60 "window.domAutomationController.send(addIFrame(%d, \"%s\"));", 60 "window.domAutomationController.send(addIFrame(%d, \"%s\"));",
61 iframe_id, 61 iframe_id,
62 url.spec().c_str()); 62 url.spec().c_str());
63 chrome::GetActiveWebContents(browser)->GetRenderViewHost()-> 63 chrome::GetActiveWebContents(browser)->GetRenderViewHost()->
64 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(script)); 64 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(script));
65 ui_test_utils::RunMessageLoop(); 65 content::RunMessageLoop();
66 66
67 EXPECT_EQ(base::StringPrintf("\"%d\"", iframe_id), javascript_response_); 67 EXPECT_EQ(base::StringPrintf("\"%d\"", iframe_id), javascript_response_);
68 registrar_.RemoveAll(); 68 registrar_.RemoveAll();
69 // Now that we loaded the iframe, let's fetch its src. 69 // Now that we loaded the iframe, let's fetch its src.
70 script = base::StringPrintf( 70 script = base::StringPrintf(
71 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id); 71 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id);
72 std::string iframe_src; 72 std::string iframe_src;
73 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString( 73 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString(
74 chrome::GetActiveWebContents(browser)->GetRenderViewHost(), 74 chrome::GetActiveWebContents(browser)->GetRenderViewHost(),
75 L"", UTF8ToWide(script), &iframe_src)); 75 L"", UTF8ToWide(script), &iframe_src));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 void AddWatchAndWaitForNotification(content::RenderViewHost* render_view_host, 137 void AddWatchAndWaitForNotification(content::RenderViewHost* render_view_host,
138 const std::wstring& iframe_xpath) { 138 const std::wstring& iframe_xpath) {
139 LOG(WARNING) << "will add geolocation watch"; 139 LOG(WARNING) << "will add geolocation watch";
140 std::string script = 140 std::string script =
141 "window.domAutomationController.setAutomationId(0);" 141 "window.domAutomationController.setAutomationId(0);"
142 "window.domAutomationController.send(geoStart());"; 142 "window.domAutomationController.send(geoStart());";
143 render_view_host->ExecuteJavascriptInWebFrame(WideToUTF16Hack(iframe_xpath), 143 render_view_host->ExecuteJavascriptInWebFrame(WideToUTF16Hack(iframe_xpath),
144 UTF8ToUTF16(script)); 144 UTF8ToUTF16(script));
145 ui_test_utils::RunMessageLoop(); 145 content::RunMessageLoop();
146 registrar_.RemoveAll(); 146 registrar_.RemoveAll();
147 LOG(WARNING) << "got geolocation watch" << javascript_response_; 147 LOG(WARNING) << "got geolocation watch" << javascript_response_;
148 EXPECT_NE("\"0\"", javascript_response_); 148 EXPECT_NE("\"0\"", javascript_response_);
149 if (wait_for_infobar_) { 149 if (wait_for_infobar_) {
150 EXPECT_TRUE(infobar_); 150 EXPECT_TRUE(infobar_);
151 } else { 151 } else {
152 EXPECT_TRUE(navigation_completed_); 152 EXPECT_TRUE(navigation_completed_);
153 } 153 }
154 } 154 }
155 155
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 "window.domAutomationController.setAutomationId(0);" 660 "window.domAutomationController.setAutomationId(0);"
661 "window.domAutomationController.send(window.close());"; 661 "window.domAutomationController.send(window.close());";
662 bool result = 662 bool result =
663 content::ExecuteJavaScript( 663 content::ExecuteJavaScript(
664 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(), 664 chrome::GetActiveWebContents(current_browser_)->GetRenderViewHost(),
665 L"", UTF8ToWide(script)); 665 L"", UTF8ToWide(script));
666 EXPECT_EQ(result, true); 666 EXPECT_EQ(result, true);
667 } 667 }
668 668
669 } // namespace 669 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/access_token_store_browsertest.cc ('k') | chrome/browser/history/history_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698