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

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: Use 'invisible' CSS class name 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 372 }
373 373
374 void FlushBlacklistPolicy() { 374 void FlushBlacklistPolicy() {
375 // Updates of the URLBlacklist are done on IO, after building the blacklist 375 // Updates of the URLBlacklist are done on IO, after building the blacklist
376 // on FILE, which is initiated from IO. 376 // on FILE, which is initiated from IO.
377 content::RunAllPendingInMessageLoop(BrowserThread::IO); 377 content::RunAllPendingInMessageLoop(BrowserThread::IO);
378 content::RunAllPendingInMessageLoop(BrowserThread::FILE); 378 content::RunAllPendingInMessageLoop(BrowserThread::FILE);
379 content::RunAllPendingInMessageLoop(BrowserThread::IO); 379 content::RunAllPendingInMessageLoop(BrowserThread::IO);
380 } 380 }
381 381
382 bool ContainsVisibleElement(content::WebContents* contents,
383 const std::string& id) {
384 bool result;
385 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
386 contents,
387 "var elem = document.getElementById('" + id + "');"
388 "domAutomationController.send(!!elem && !elem.hidden);",
389 &result));
390 return result;
391 }
392
382 #if defined(OS_CHROMEOS) 393 #if defined(OS_CHROMEOS)
383 // Volume observer mock used by the audio policy tests. 394 // Volume observer mock used by the audio policy tests.
384 class TestVolumeObserver : public chromeos::AudioHandler::VolumeObserver { 395 class TestVolumeObserver : public chromeos::AudioHandler::VolumeObserver {
385 public: 396 public:
386 TestVolumeObserver() {} 397 TestVolumeObserver() {}
387 virtual ~TestVolumeObserver() {} 398 virtual ~TestVolumeObserver() {}
388 399
389 MOCK_METHOD0(OnVolumeChanged, void()); 400 MOCK_METHOD0(OnVolumeChanged, void());
390 MOCK_METHOD0(OnMuteToggled, void()); 401 MOCK_METHOD0(OnMuteToggled, void());
391 402
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, 1094 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY,
1084 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); 1095 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
1085 UpdateProviderPolicy(policies); 1096 UpdateProviderPolicy(policies);
1086 // The existing devtools window should have closed. 1097 // The existing devtools window should have closed.
1087 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); 1098 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents));
1088 // And it's not possible to open it again. 1099 // And it's not possible to open it again.
1089 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); 1100 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS));
1090 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); 1101 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents));
1091 } 1102 }
1092 1103
1104 IN_PROC_BROWSER_TEST_F(PolicyTest, WebStoreIconHidden) {
1105 // Verifies that the web store icons can be hidden from the new tab page.
1106
1107 // Open new tab page and look for the web store icons.
1108 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
1109 content::WebContents* contents = chrome::GetActiveWebContents(browser());
1110
1111 #if !defined(OS_CHROMEOS)
1112 // Look for web store's app ID in the apps page.
1113 EXPECT_TRUE(ContainsVisibleElement(contents,
1114 "ahfgeienlihckogmohjhadlkjgocpleb"));
1115 #endif
1116
1117 // The next NTP has no footer.
1118 if (ContainsVisibleElement(contents, "footer"))
1119 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link"));
1120
1121 // Turn off the web store icons.
1122 PolicyMap policies;
1123 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY,
1124 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
1125 UpdateProviderPolicy(policies);
1126
1127 // The web store icons should now be hidden.
1128 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
1129 contents = chrome::GetActiveWebContents(browser());
1130 EXPECT_FALSE(ContainsVisibleElement(contents,
1131 "ahfgeienlihckogmohjhadlkjgocpleb"));
1132 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link"));
1133 }
1134
1093 // This policy isn't available on Chrome OS. 1135 // This policy isn't available on Chrome OS.
1094 #if !defined(OS_CHROMEOS) 1136 #if !defined(OS_CHROMEOS)
1095 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { 1137 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) {
1096 // Verifies that the download directory can be forced by policy. 1138 // Verifies that the download directory can be forced by policy.
1097 1139
1098 // Set the initial download directory. 1140 // Set the initial download directory.
1099 base::ScopedTempDir initial_dir; 1141 base::ScopedTempDir initial_dir;
1100 ASSERT_TRUE(initial_dir.CreateUniqueTempDir()); 1142 ASSERT_TRUE(initial_dir.CreateUniqueTempDir());
1101 browser()->profile()->GetPrefs()->SetFilePath( 1143 browser()->profile()->GetPrefs()->SetFilePath(
1102 prefs::kDownloadDefaultDirectory, initial_dir.path()); 1144 prefs::kDownloadDefaultDirectory, initial_dir.path());
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 this)); 1896 this));
1855 1897
1856 MessageLoop::current()->Run(); 1898 MessageLoop::current()->Run();
1857 } 1899 }
1858 1900
1859 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, 1901 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance,
1860 MediaStreamDevicesControllerBrowserTest, 1902 MediaStreamDevicesControllerBrowserTest,
1861 testing::Bool()); 1903 testing::Bool());
1862 1904
1863 } // namespace policy 1905 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698