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

Side by Side Diff: chrome/browser/ui/webui/uber/uber_ui_browsertest.cc

Issue 2830983005: Remove old webui History page on desktop and mobile (Closed)
Patch Set: merge Created 3 years, 7 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
« no previous file with comments | « chrome/browser/ui/webui/uber/uber_ui.cc ('k') | chrome/common/chrome_features.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 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 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 <string> 5 #include <string>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/test/scoped_feature_list.h" 10 #include "base/test/scoped_feature_list.h"
(...skipping 20 matching lines...) Expand all
31 31
32 bool GetJsBool(const char* js) { 32 bool GetJsBool(const char* js) {
33 bool result = false; 33 bool result = false;
34 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 34 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
35 GetWebContents(), 35 GetWebContents(),
36 std::string("domAutomationController.send(") + js + ");", 36 std::string("domAutomationController.send(") + js + ");",
37 &result)); 37 &result));
38 return result; 38 return result;
39 } 39 }
40 40
41 void RunJs(const char* js) { 41 void SelectTab(const std::string& name) {
42 ASSERT_TRUE(content::ExecuteScript(GetWebContents(), js)); 42 ASSERT_TRUE(content::ExecuteScript(
43 } 43 GetWebContents(),
44 44 std::string("var data = {pageId: '") + name + "'};" +
45 void SelectTab() { 45 "uber.invokeMethodOnWindow(this, 'changeSelection', data);"));
46 RunJs("var data = {pageId: 'history'};"
47 "uber.invokeMethodOnWindow(this, 'changeSelection', data);");
48 } 46 }
49 47
50 private: 48 private:
51 content::WebContents* GetWebContents() { 49 content::WebContents* GetWebContents() {
52 return browser()->tab_strip_model()->GetActiveWebContents(); 50 return browser()->tab_strip_model()->GetActiveWebContents();
53 } 51 }
54 52
55 DISALLOW_COPY_AND_ASSIGN(UberUIBrowserTest); 53 DISALLOW_COPY_AND_ASSIGN(UberUIBrowserTest);
56 }; 54 };
57 55
58 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, HistoryOverride) {
59 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL));
60
61 RunJs("var overrideCalled = false;"
62 "var uber_frame = {"
63 " setNavigationOverride: function() {"
64 " overrideCalled = true;"
65 " },"
66 "};");
67
68 scoped_refptr<const extensions::Extension> extension =
69 extensions::ExtensionBuilder()
70 .SetManifest(
71 extensions::DictionaryBuilder()
72 .Set("name", "History Override")
73 .Set("version", "1")
74 .Set("manifest_version", 2)
75 .Set("permission",
76 extensions::ListBuilder().Append("history").Build())
77 .Build())
78 .Build();
79
80 ExtensionService* service = extensions::ExtensionSystem::Get(
81 browser()->profile())->extension_service();
82 // Load extension. UberUI overrides history navigation.
83 // In this test, injected script will be called instead.
84 service->AddExtension(extension.get());
85
86 EXPECT_TRUE(GetJsBool("overrideCalled"));
87 }
88
89 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, EnableMdExtensionsHidesExtensions) { 56 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, EnableMdExtensionsHidesExtensions) {
90 base::test::ScopedFeatureList scoped_feature_list; 57 base::test::ScopedFeatureList scoped_feature_list;
91 scoped_feature_list.InitAndEnableFeature(features::kMaterialDesignExtensions); 58 scoped_feature_list.InitWithFeatures({features::kMaterialDesignExtensions},
59 {features::kMaterialDesignSettings});
92 60
93 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL)); 61 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL));
94 SelectTab(); 62 SelectTab("settings");
95 EXPECT_TRUE(GetJsBool("$('extensions').hidden")); 63 EXPECT_TRUE(GetJsBool("$('extensions').hidden"));
96 } 64 }
97 65
98 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, EnableMdHistoryHidesHistory) {
99 base::test::ScopedFeatureList scoped_feature_list;
100 scoped_feature_list.InitAndEnableFeature(features::kMaterialDesignHistory);
101
102 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL));
103 SelectTab();
104 EXPECT_TRUE(GetJsBool("$('history').hidden"));
105 }
106
107 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, EnableMdSettingsHidesSettings) { 66 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, EnableMdSettingsHidesSettings) {
108 base::test::ScopedFeatureList scoped_feature_list; 67 base::test::ScopedFeatureList scoped_feature_list;
109 scoped_feature_list.InitAndEnableFeature(features::kMaterialDesignSettings); 68 scoped_feature_list.InitWithFeatures({features::kMaterialDesignSettings},
69 {features::kMaterialDesignExtensions});
110 70
111 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL)); 71 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL));
112 SelectTab(); 72 SelectTab("extensions");
113 EXPECT_TRUE(GetJsBool("$('settings').hidden && $('help').hidden")); 73 EXPECT_TRUE(GetJsBool("$('settings').hidden && $('help').hidden"));
114 } 74 }
115 75
116 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest, 76 IN_PROC_BROWSER_TEST_F(UberUIBrowserTest,
117 EnableSettingsWindowHidesSettingsAndHelp) { 77 EnableSettingsWindowHidesSettingsAndHelp) {
78 base::test::ScopedFeatureList scoped_feature_list;
79 scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignSettings);
80
118 base::CommandLine::ForCurrentProcess()->AppendSwitch( 81 base::CommandLine::ForCurrentProcess()->AppendSwitch(
119 ::switches::kEnableSettingsWindow); 82 ::switches::kEnableSettingsWindow);
120 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL)); 83 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIUberFrameURL));
121 SelectTab(); 84 SelectTab("extensions");
122 EXPECT_TRUE(GetJsBool("$('settings').hidden && $('help').hidden")); 85 EXPECT_TRUE(GetJsBool("$('settings').hidden && $('help').hidden"));
123 } 86 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/uber/uber_ui.cc ('k') | chrome/common/chrome_features.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698