Chromium Code Reviews| Index: chrome/browser/policy/policy_browsertest.cc |
| diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc |
| index 494fe79afd276ac25d0e72cba039d717eb1581db..eae10546881629f9c81889d96be7c2aa7976263f 100644 |
| --- a/chrome/browser/policy/policy_browsertest.cc |
| +++ b/chrome/browser/policy/policy_browsertest.cc |
| @@ -647,6 +647,54 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { |
| EXPECT_EQ(GURL(chrome::kAboutBlankURL), web_contents->GetURL()); |
| } |
| +IN_PROC_BROWSER_TEST_F(PolicyTest, SafeSearch) { |
| + // Verifies that requests to the Google Search engine with the SafeSearch |
| + // set the safe=active&ssui=on parameters at the end of the query. |
|
Pam (message me for reviews)
2012/10/17 11:37:37
nit: missing some words here ("with the SafeSearch
|
| + TemplateURLService* service = TemplateURLServiceFactory::GetForProfile( |
| + browser()->profile()); |
| + ui_test_utils::WaitForTemplateURLServiceToLoad(service); |
| + |
| + // First check that nothing happens. |
| + chrome::FocusLocationBar(browser()); |
| + LocationBar* location_bar = browser()->window()->GetLocationBar(); |
| + ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); |
| + OmniboxEditModel* model = location_bar->GetLocationEntry()->model(); |
| + EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid()); |
| + content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
| + GURL expected_wo("http://google.com/"); |
|
Joao da Silva
2012/10/16 16:26:46
Use a descriptive variable name, such as |expected
Sergiu
2012/10/17 14:48:58
Done.
|
| + EXPECT_EQ(expected_wo, web_contents->GetURL()); |
| + |
| + PrefService* prefs = browser()->profile()->GetPrefs(); |
| + EXPECT_FALSE(prefs->IsManagedPreference(prefs::kSafeSearchEnabled)); |
| + EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeSearchEnabled)); |
| + |
| + // Override the default SafeSearch setting using policies. |
| + PolicyMap policies; |
| + policies.Set(key::kSafeSearchEnabled, POLICY_LEVEL_MANDATORY, |
| + POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
| + provider_.UpdateChromePolicy(policies); |
| + |
| + EXPECT_TRUE(prefs->IsManagedPreference(prefs::kSafeSearchEnabled)); |
| + EXPECT_TRUE(prefs->GetBoolean(prefs::kSafeSearchEnabled)); |
| + |
| + content::WindowedNotificationObserver observer( |
| + content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| + content::NotificationService::AllSources()); |
| + |
| + // Verify that searching from the google.com works |
|
Joao da Silva
2012/10/16 16:26:46
nit: terminate sentence
Pam (message me for reviews)
2012/10/17 11:37:37
Also no "the" before "google.com"
Sergiu
2012/10/17 14:48:58
Done.
|
| + chrome::FocusLocationBar(browser()); |
| + location_bar = browser()->window()->GetLocationBar(); |
| + ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); |
| + observer.Wait(); |
| + model = location_bar->GetLocationEntry()->model(); |
| + EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid()); |
| + web_contents = chrome::GetActiveWebContents(browser()); |
| + std::string expected_url("http://google.com/?"); |
| + expected_url += chrome::kSSearchParamsSingle; |
| + GURL expected_w(expected_url); |
|
Joao da Silva
2012/10/16 16:26:46
Use a descriptive name: |expected_with_params|
Sergiu
2012/10/17 14:48:58
Done.
|
| + EXPECT_EQ(expected_w, web_contents->GetURL()); |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) { |
| CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableInstantExtendedAPI); |