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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index f3c28ef3165f453410f5fc3c8c9bb241f12c5496..d6ae109d01e81fc436b88b08e1e54ba811c5373f 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -1097,6 +1097,39 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) {
EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents));
}
+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.
+ bool result;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
+ contents,
+ "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.
+ &result));
+ return result;
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyTest, WebStoreIconHidden) {
+ // Verifies that the web store icons can be hidden from the new tab page.
+
+ // Open new tab page and look for the web store icons.
+ ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
+ content::WebContents* contents = chrome::GetActiveWebContents(browser());
+ 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.
+ // The next NTP has no footer.
+ if (ContainsElement(contents, "footer"))
+ 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.
+
+ // Turn off the web store icons.
+ PolicyMap policies;
+ policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
+ UpdateProviderPolicy(policies);
+
+ // The web store icons should now be hidden.
+ ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
+ contents = chrome::GetActiveWebContents(browser());
+ EXPECT_FALSE(ContainsElement(contents, "ahfgeienlihckogmohjhadlkjgocpleb"));
+ EXPECT_FALSE(ContainsElement(contents, "chrome-web-store-link"));
+}
+
// This policy isn't available on Chrome OS.
#if !defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) {
« 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