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

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: rebase Created 7 years, 10 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 382 }
383 383
384 void FlushBlacklistPolicy() { 384 void FlushBlacklistPolicy() {
385 // Updates of the URLBlacklist are done on IO, after building the blacklist 385 // Updates of the URLBlacklist are done on IO, after building the blacklist
386 // on FILE, which is initiated from IO. 386 // on FILE, which is initiated from IO.
387 content::RunAllPendingInMessageLoop(BrowserThread::IO); 387 content::RunAllPendingInMessageLoop(BrowserThread::IO);
388 content::RunAllPendingInMessageLoop(BrowserThread::FILE); 388 content::RunAllPendingInMessageLoop(BrowserThread::FILE);
389 content::RunAllPendingInMessageLoop(BrowserThread::IO); 389 content::RunAllPendingInMessageLoop(BrowserThread::IO);
390 } 390 }
391 391
392 bool ContainsVisibleElement(content::WebContents* contents,
393 const std::string& id) {
394 bool result;
395 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
396 contents,
397 "var elem = document.getElementById('" + id + "');"
398 "domAutomationController.send("
399 " !!elem && !elem.classList.contains('invisible'));",
400 &result));
401 return result;
402 }
403
392 #if defined(OS_CHROMEOS) 404 #if defined(OS_CHROMEOS)
393 // Volume observer mock used by the audio policy tests. 405 // Volume observer mock used by the audio policy tests.
394 class TestVolumeObserver : public chromeos::AudioHandler::VolumeObserver { 406 class TestVolumeObserver : public chromeos::AudioHandler::VolumeObserver {
395 public: 407 public:
396 TestVolumeObserver() {} 408 TestVolumeObserver() {}
397 virtual ~TestVolumeObserver() {} 409 virtual ~TestVolumeObserver() {}
398 410
399 MOCK_METHOD0(OnVolumeChanged, void()); 411 MOCK_METHOD0(OnVolumeChanged, void());
400 MOCK_METHOD0(OnMuteToggled, void()); 412 MOCK_METHOD0(OnMuteToggled, void());
401 413
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, 1123 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY,
1112 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); 1124 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
1113 UpdateProviderPolicy(policies); 1125 UpdateProviderPolicy(policies);
1114 // The existing devtools window should have closed. 1126 // The existing devtools window should have closed.
1115 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); 1127 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents));
1116 // And it's not possible to open it again. 1128 // And it's not possible to open it again.
1117 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); 1129 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS));
1118 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); 1130 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents));
1119 } 1131 }
1120 1132
1133 IN_PROC_BROWSER_TEST_F(PolicyTest, WebStoreIconHidden) {
1134 // Verifies that the web store icons can be hidden from the new tab page.
1135
1136 // Open new tab page and look for the web store icons.
1137 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
1138 content::WebContents* contents =
1139 browser()->tab_strip_model()->GetActiveWebContents();
1140
1141 #if !defined(OS_CHROMEOS)
1142 // Look for web store's app ID in the apps page.
1143 EXPECT_TRUE(ContainsVisibleElement(contents,
1144 "ahfgeienlihckogmohjhadlkjgocpleb"));
1145 #endif
1146
1147 // The next NTP has no footer.
1148 if (ContainsVisibleElement(contents, "footer"))
1149 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link"));
1150
1151 // Turn off the web store icons.
1152 PolicyMap policies;
1153 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY,
1154 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
1155 UpdateProviderPolicy(policies);
1156
1157 // The web store icons should now be hidden.
1158 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
1159 EXPECT_FALSE(ContainsVisibleElement(contents,
1160 "ahfgeienlihckogmohjhadlkjgocpleb"));
1161 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link"));
1162 }
1163
1121 // This policy isn't available on Chrome OS. 1164 // This policy isn't available on Chrome OS.
1122 #if !defined(OS_CHROMEOS) 1165 #if !defined(OS_CHROMEOS)
1123 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { 1166 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) {
1124 // Verifies that the download directory can be forced by policy. 1167 // Verifies that the download directory can be forced by policy.
1125 1168
1126 // Set the initial download directory. 1169 // Set the initial download directory.
1127 base::ScopedTempDir initial_dir; 1170 base::ScopedTempDir initial_dir;
1128 ASSERT_TRUE(initial_dir.CreateUniqueTempDir()); 1171 ASSERT_TRUE(initial_dir.CreateUniqueTempDir());
1129 browser()->profile()->GetPrefs()->SetFilePath( 1172 browser()->profile()->GetPrefs()->SetFilePath(
1130 prefs::kDownloadDefaultDirectory, initial_dir.path()); 1173 prefs::kDownloadDefaultDirectory, initial_dir.path());
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 this)); 1944 this));
1902 1945
1903 MessageLoop::current()->Run(); 1946 MessageLoop::current()->Run();
1904 } 1947 }
1905 1948
1906 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, 1949 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance,
1907 MediaStreamDevicesControllerBrowserTest, 1950 MediaStreamDevicesControllerBrowserTest,
1908 testing::Bool()); 1951 testing::Bool());
1909 1952
1910 } // namespace policy 1953 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_pref_store_unittest.cc ('k') | chrome/browser/resources/ntp4/new_tab.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698