| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <string> | |
| 6 #include <utility> | |
| 7 | |
| 8 #include "base/command_line.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/test/scoped_feature_list.h" | |
| 11 #include "chrome/browser/extensions/extension_service.h" | |
| 12 #include "chrome/browser/extensions/test_extension_system.h" | |
| 13 #include "chrome/browser/profiles/profile.h" | |
| 14 #include "chrome/browser/ui/browser.h" | |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 16 #include "chrome/common/chrome_features.h" | |
| 17 #include "chrome/common/chrome_switches.h" | |
| 18 #include "chrome/common/url_constants.h" | |
| 19 #include "chrome/test/base/ui_test_utils.h" | |
| 20 #include "chrome/test/base/web_ui_browser_test.h" | |
| 21 #include "content/public/common/content_switches.h" | |
| 22 #include "content/public/test/browser_test_utils.h" | |
| 23 #include "extensions/browser/extension_registry.h" | |
| 24 #include "extensions/common/extension.h" | |
| 25 #include "extensions/common/extension_builder.h" | |
| 26 | |
| 27 class UberUIBrowserTest : public WebUIBrowserTest { | |
| 28 public: | |
| 29 UberUIBrowserTest() {} | |
| 30 ~UberUIBrowserTest() override {} | |
| 31 | |
| 32 bool GetJsBool(const char* js) { | |
| 33 bool result = false; | |
| 34 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | |
| 35 GetWebContents(), | |
| 36 std::string("domAutomationController.send(") + js + ");", | |
| 37 &result)); | |
| 38 return result; | |
| 39 } | |
| 40 | |
| 41 void SelectTab(const std::string& name) { | |
| 42 ASSERT_TRUE(content::ExecuteScript( | |
| 43 GetWebContents(), | |
| 44 std::string("var data = {pageId: '") + name + "'};" + | |
| 45 "uber.invokeMethodOnWindow(this, 'changeSelection', data);")); | |
| 46 } | |
| 47 | |
| 48 private: | |
| 49 content::WebContents* GetWebContents() { | |
| 50 return browser()->tab_strip_model()->GetActiveWebContents(); | |
| 51 } | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(UberUIBrowserTest); | |
| 54 }; | |
| 55 | |
| 56 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, EnableMdExtensionsHidesExtensions) { | |
| 57 base::test::ScopedFeatureList scoped_feature_list; | |
| 58 scoped_feature_list.InitWithFeatures({features::kMaterialDesignExtensions}, | |
| 59 {features::kMaterialDesignSettings}); | |
| 60 | |
| 61 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL)); | |
| 62 SelectTab("settings"); | |
| 63 EXPECT_TRUE(GetJsBool("$('extensions').hidden")); | |
| 64 } | |
| 65 | |
| 66 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, EnableMdSettingsHidesSettings) { | |
| 67 base::test::ScopedFeatureList scoped_feature_list; | |
| 68 scoped_feature_list.InitWithFeatures({features::kMaterialDesignSettings}, | |
| 69 {features::kMaterialDesignExtensions}); | |
| 70 | |
| 71 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL)); | |
| 72 SelectTab("extensions"); | |
| 73 EXPECT_TRUE(GetJsBool("$('settings').hidden && $('help').hidden")); | |
| 74 } | |
| 75 | |
| 76 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, | |
| 77 EnableSettingsWindowHidesSettingsAndHelp) { | |
| 78 base::test::ScopedFeatureList scoped_feature_list; | |
| 79 scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignSettings); | |
| 80 | |
| 81 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 82 ::switches::kEnableSettingsWindow); | |
| 83 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL)); | |
| 84 SelectTab("extensions"); | |
| 85 EXPECT_TRUE(GetJsBool("$('settings').hidden && $('help').hidden")); | |
| 86 } | |
| OLD | NEW |