OLD | NEW |
---|---|
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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); | 640 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); |
641 EXPECT_TRUE(service->GetDefaultSearchProvider()); | 641 EXPECT_TRUE(service->GetDefaultSearchProvider()); |
642 provider_.UpdateChromePolicy(policies); | 642 provider_.UpdateChromePolicy(policies); |
643 EXPECT_FALSE(service->GetDefaultSearchProvider()); | 643 EXPECT_FALSE(service->GetDefaultSearchProvider()); |
644 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); | 644 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); |
645 // This means that submitting won't trigger any action. | 645 // This means that submitting won't trigger any action. |
646 EXPECT_FALSE(model->CurrentMatch().destination_url.is_valid()); | 646 EXPECT_FALSE(model->CurrentMatch().destination_url.is_valid()); |
647 EXPECT_EQ(GURL(chrome::kAboutBlankURL), web_contents->GetURL()); | 647 EXPECT_EQ(GURL(chrome::kAboutBlankURL), web_contents->GetURL()); |
648 } | 648 } |
649 | 649 |
650 IN_PROC_BROWSER_TEST_F(PolicyTest, SafeSearch) { | |
651 // Verifies that requests to the Google Search engine with the SafeSearch | |
652 // 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
| |
653 TemplateURLService* service = TemplateURLServiceFactory::GetForProfile( | |
654 browser()->profile()); | |
655 ui_test_utils::WaitForTemplateURLServiceToLoad(service); | |
656 | |
657 // First check that nothing happens. | |
658 chrome::FocusLocationBar(browser()); | |
659 LocationBar* location_bar = browser()->window()->GetLocationBar(); | |
660 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); | |
661 OmniboxEditModel* model = location_bar->GetLocationEntry()->model(); | |
662 EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid()); | |
663 content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); | |
664 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.
| |
665 EXPECT_EQ(expected_wo, web_contents->GetURL()); | |
666 | |
667 PrefService* prefs = browser()->profile()->GetPrefs(); | |
668 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kSafeSearchEnabled)); | |
669 EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeSearchEnabled)); | |
670 | |
671 // Override the default SafeSearch setting using policies. | |
672 PolicyMap policies; | |
673 policies.Set(key::kSafeSearchEnabled, POLICY_LEVEL_MANDATORY, | |
674 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); | |
675 provider_.UpdateChromePolicy(policies); | |
676 | |
677 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kSafeSearchEnabled)); | |
678 EXPECT_TRUE(prefs->GetBoolean(prefs::kSafeSearchEnabled)); | |
679 | |
680 content::WindowedNotificationObserver observer( | |
681 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | |
682 content::NotificationService::AllSources()); | |
683 | |
684 // 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.
| |
685 chrome::FocusLocationBar(browser()); | |
686 location_bar = browser()->window()->GetLocationBar(); | |
687 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); | |
688 observer.Wait(); | |
689 model = location_bar->GetLocationEntry()->model(); | |
690 EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid()); | |
691 web_contents = chrome::GetActiveWebContents(browser()); | |
692 std::string expected_url("http://google.com/?"); | |
693 expected_url += chrome::kSSearchParamsSingle; | |
694 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.
| |
695 EXPECT_EQ(expected_w, web_contents->GetURL()); | |
696 } | |
697 | |
650 IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) { | 698 IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) { |
651 CommandLine::ForCurrentProcess()->AppendSwitch( | 699 CommandLine::ForCurrentProcess()->AppendSwitch( |
652 switches::kEnableInstantExtendedAPI); | 700 switches::kEnableInstantExtendedAPI); |
653 | 701 |
654 // Adding the kEnableInstantExtendedAPI is not enough since | 702 // Adding the kEnableInstantExtendedAPI is not enough since |
655 // IsInstantExtendedAPIEnabled does not return true on CHANNEL_DEV. | 703 // IsInstantExtendedAPIEnabled does not return true on CHANNEL_DEV. |
656 if (!chrome::search::IsInstantExtendedAPIEnabled(browser()->profile())) | 704 if (!chrome::search::IsInstantExtendedAPIEnabled(browser()->profile())) |
657 return; | 705 return; |
658 | 706 |
659 // Verifies that a default search is made using the provider configured via | 707 // Verifies that a default search is made using the provider configured via |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1573 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size())); | 1621 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size())); |
1574 // HomepageLocation has policy ID 1. | 1622 // HomepageLocation has policy ID 1. |
1575 EXPECT_NE(std::string::npos, text.find("<br>1 ---")); | 1623 EXPECT_NE(std::string::npos, text.find("<br>1 ---")); |
1576 // ShowHomeButton has policy ID 35. | 1624 // ShowHomeButton has policy ID 35. |
1577 EXPECT_NE(std::string::npos, text.find("<br>35 ---")); | 1625 EXPECT_NE(std::string::npos, text.find("<br>35 ---")); |
1578 // BookmarkBarEnabled has policy ID 82. | 1626 // BookmarkBarEnabled has policy ID 82. |
1579 EXPECT_NE(std::string::npos, text.find("<br>82 ---")); | 1627 EXPECT_NE(std::string::npos, text.find("<br>82 ---")); |
1580 } | 1628 } |
1581 | 1629 |
1582 } // namespace policy | 1630 } // namespace policy |
OLD | NEW |