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

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

Issue 11859029: Add a policy to hide the Web Store on new tabs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Check that footer exists before removing icon Created 7 years, 11 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 <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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, 1090 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY,
1091 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); 1091 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
1092 UpdateProviderPolicy(policies); 1092 UpdateProviderPolicy(policies);
1093 // The existing devtools window should have closed. 1093 // The existing devtools window should have closed.
1094 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); 1094 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents));
1095 // And it's not possible to open it again. 1095 // And it's not possible to open it again.
1096 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); 1096 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS));
1097 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); 1097 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents));
1098 } 1098 }
1099 1099
1100 bool ContainsElement(content::WebContents* contents, const std::string id) {
Joao da Silva 2013/01/21 07:44:51 Helper functions like this come before the tests,
dconnelly 2013/01/21 09:39:03 Done.
1101 bool result;
1102 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1103 contents,
1104 "domAutomationController.send(!!document.getElementById(\"" + id + "\"))",
Joao da Silva 2013/01/21 07:44:51 Single quotes could be used instead of \"; just a
dconnelly 2013/01/21 09:39:03 Done.
1105 &result));
1106 return result;
1107 }
1108
1109 IN_PROC_BROWSER_TEST_F(PolicyTest, WebStoreIconHidden) {
1110 // Verifies that the web store icons can be hidden from the new tab page.
1111
1112 // Open new tab page and look for the web store icons.
1113 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
1114 content::WebContents* contents = chrome::GetActiveWebContents(browser());
1115 EXPECT_TRUE(ContainsElement(contents, "ahfgeienlihckogmohjhadlkjgocpleb"));
Joao da Silva 2013/01/21 07:44:51 What does that ID refer to? Please comment it (I'm
dconnelly 2013/01/21 09:39:03 Done.
1116 // The next NTP has no footer.
1117 if (ContainsElement(contents, "footer"))
1118 EXPECT_TRUE(ContainsElement(contents, "chrome-web-store-link"));
Joao da Silva 2013/01/21 07:44:51 nit: indent (2 spaces instead of 4)
dconnelly 2013/01/21 09:39:03 Done.
1119
1120 // Turn off the web store icons.
1121 PolicyMap policies;
1122 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY,
1123 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
1124 UpdateProviderPolicy(policies);
1125
1126 // The web store icons should now be hidden.
1127 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
1128 contents = chrome::GetActiveWebContents(browser());
1129 EXPECT_FALSE(ContainsElement(contents, "ahfgeienlihckogmohjhadlkjgocpleb"));
1130 EXPECT_FALSE(ContainsElement(contents, "chrome-web-store-link"));
1131 }
1132
1100 // This policy isn't available on Chrome OS. 1133 // This policy isn't available on Chrome OS.
1101 #if !defined(OS_CHROMEOS) 1134 #if !defined(OS_CHROMEOS)
1102 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { 1135 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) {
1103 // Verifies that the download directory can be forced by policy. 1136 // Verifies that the download directory can be forced by policy.
1104 1137
1105 // Set the initial download directory. 1138 // Set the initial download directory.
1106 base::ScopedTempDir initial_dir; 1139 base::ScopedTempDir initial_dir;
1107 ASSERT_TRUE(initial_dir.CreateUniqueTempDir()); 1140 ASSERT_TRUE(initial_dir.CreateUniqueTempDir());
1108 browser()->profile()->GetPrefs()->SetFilePath( 1141 browser()->profile()->GetPrefs()->SetFilePath(
1109 prefs::kDownloadDefaultDirectory, initial_dir.path()); 1142 prefs::kDownloadDefaultDirectory, initial_dir.path());
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size())); 1786 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size()));
1754 // HomepageLocation has policy ID 1. 1787 // HomepageLocation has policy ID 1.
1755 EXPECT_NE(std::string::npos, text.find("<br>1 ---")); 1788 EXPECT_NE(std::string::npos, text.find("<br>1 ---"));
1756 // ShowHomeButton has policy ID 35. 1789 // ShowHomeButton has policy ID 35.
1757 EXPECT_NE(std::string::npos, text.find("<br>35 ---")); 1790 EXPECT_NE(std::string::npos, text.find("<br>35 ---"));
1758 // BookmarkBarEnabled has policy ID 82. 1791 // BookmarkBarEnabled has policy ID 82.
1759 EXPECT_NE(std::string::npos, text.find("<br>82 ---")); 1792 EXPECT_NE(std::string::npos, text.find("<br>82 ---"));
1760 } 1793 }
1761 1794
1762 } // namespace policy 1795 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_pref_store_unittest.cc ('k') | chrome/browser/resources/ntp4/apps_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698