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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 10913043: Convert the popups pyauto test to browser_tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 3 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/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 ASCIIToWide( 110 ASCIIToWide(
111 "var hasError = false;" 111 "var hasError = false;"
112 "var error = document.getElementById('errorDetails');" 112 "var error = document.getElementById('errorDetails');"
113 "if (error)" 113 "if (error)"
114 " hasError = error.textContent.indexOf('Error 138') == 0;" 114 " hasError = error.textContent.indexOf('Error 138') == 0;"
115 "domAutomationController.send(hasError);"), 115 "domAutomationController.send(hasError);"),
116 &result)); 116 &result));
117 EXPECT_TRUE(result); 117 EXPECT_TRUE(result);
118 } 118 }
119 119
120 void SendToOmniboxAndSubmit(LocationBar* location_bar, const string16& input) {
121 OmniboxView* omnibox = location_bar->GetLocationEntry();
122 omnibox->model()->OnSetFocus(false);
123 omnibox->SetUserText(input);
124 location_bar->AcceptInput();
125 while (!omnibox->model()->autocomplete_controller()->done()) {
126 content::WindowedNotificationObserver observer(
127 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
128 content::NotificationService::AllSources());
129 observer.Wait();
130 }
131 }
132
133 // Downloads a file named |file| and expects it to be saved to |dir|, which 120 // Downloads a file named |file| and expects it to be saved to |dir|, which
134 // must be empty. 121 // must be empty.
135 void DownloadAndVerifyFile( 122 void DownloadAndVerifyFile(
136 Browser* browser, const FilePath& dir, const FilePath& file) { 123 Browser* browser, const FilePath& dir, const FilePath& file) {
137 content::DownloadManager* download_manager = 124 content::DownloadManager* download_manager =
138 content::BrowserContext::GetDownloadManager(browser->profile()); 125 content::BrowserContext::GetDownloadManager(browser->profile());
139 content::DownloadTestObserverTerminal observer( 126 content::DownloadTestObserverTerminal observer(
140 download_manager, 1, 127 download_manager, 1,
141 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); 128 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL);
142 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 129 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 POLICY_SCOPE_USER, base::Value::CreateStringValue(kSearchURL)); 254 POLICY_SCOPE_USER, base::Value::CreateStringValue(kSearchURL));
268 provider_.UpdateChromePolicy(policies); 255 provider_.UpdateChromePolicy(policies);
269 default_search = service->GetDefaultSearchProvider(); 256 default_search = service->GetDefaultSearchProvider();
270 ASSERT_TRUE(default_search); 257 ASSERT_TRUE(default_search);
271 EXPECT_EQ(kKeyword, default_search->keyword()); 258 EXPECT_EQ(kKeyword, default_search->keyword());
272 EXPECT_EQ(kSearchURL, default_search->url()); 259 EXPECT_EQ(kSearchURL, default_search->url());
273 260
274 // Verify that searching from the omnibox uses kSearchURL. 261 // Verify that searching from the omnibox uses kSearchURL.
275 chrome::FocusLocationBar(browser()); 262 chrome::FocusLocationBar(browser());
276 LocationBar* location_bar = browser()->window()->GetLocationBar(); 263 LocationBar* location_bar = browser()->window()->GetLocationBar();
277 SendToOmniboxAndSubmit(location_bar, ASCIIToUTF16("stuff to search for")); 264 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "stuff to search for");
278 OmniboxEditModel* model = location_bar->GetLocationEntry()->model(); 265 OmniboxEditModel* model = location_bar->GetLocationEntry()->model();
279 EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid()); 266 EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid());
280 content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); 267 content::WebContents* web_contents = chrome::GetActiveWebContents(browser());
281 GURL expected("http://search.example/search?q=stuff+to+search+for"); 268 GURL expected("http://search.example/search?q=stuff+to+search+for");
282 EXPECT_EQ(expected, web_contents->GetURL()); 269 EXPECT_EQ(expected, web_contents->GetURL());
283 270
284 // Verify that searching from the omnibox can be disabled. 271 // Verify that searching from the omnibox can be disabled.
285 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 272 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
286 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, 273 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY,
287 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); 274 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false));
288 EXPECT_TRUE(service->GetDefaultSearchProvider()); 275 EXPECT_TRUE(service->GetDefaultSearchProvider());
289 provider_.UpdateChromePolicy(policies); 276 provider_.UpdateChromePolicy(policies);
290 EXPECT_FALSE(service->GetDefaultSearchProvider()); 277 EXPECT_FALSE(service->GetDefaultSearchProvider());
291 SendToOmniboxAndSubmit(location_bar, ASCIIToUTF16("should not work")); 278 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work");
292 // This means that submitting won't trigger any action. 279 // This means that submitting won't trigger any action.
293 EXPECT_FALSE(model->CurrentMatch().destination_url.is_valid()); 280 EXPECT_FALSE(model->CurrentMatch().destination_url.is_valid());
294 EXPECT_EQ(GURL("about:blank"), web_contents->GetURL()); 281 EXPECT_EQ(GURL("about:blank"), web_contents->GetURL());
295 } 282 }
296 283
297 // This policy isn't available on Chrome OS. 284 // This policy isn't available on Chrome OS.
298 #if !defined(OS_CHROMEOS) 285 #if !defined(OS_CHROMEOS)
299 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { 286 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) {
300 // Verifies that the download directory can be forced by policy. 287 // Verifies that the download directory can be forced by policy.
301 288
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, 461 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY,
475 POLICY_SCOPE_USER, whitelist.DeepCopy()); 462 POLICY_SCOPE_USER, whitelist.DeepCopy());
476 provider_.UpdateChromePolicy(policies); 463 provider_.UpdateChromePolicy(policies);
477 CheckCanOpenURL(browser(), kAAA); 464 CheckCanOpenURL(browser(), kAAA);
478 CheckURLIsBlocked(browser(), kBBB); 465 CheckURLIsBlocked(browser(), kBBB);
479 CheckCanOpenURL(browser(), kSUB_BBB); 466 CheckCanOpenURL(browser(), kSUB_BBB);
480 CheckCanOpenURL(browser(), kBBB_PATH); 467 CheckCanOpenURL(browser(), kBBB_PATH);
481 } 468 }
482 469
483 } // namespace policy 470 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/popup_blocker_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698