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

Side by Side Diff: chrome/browser/ui/extensions/hosted_app_browsertest.cc

Issue 2765083002: Hardcode extensions::util::IsNewBookmarkAppsEnabled() to true, except on Mac. (Closed)
Patch Set: remove logging Created 3 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "chrome/browser/extensions/extension_browsertest.h" 9 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_util.h" 11 #include "chrome/browser/extensions/extension_util.h"
12 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/browser/ui/extensions/app_launch_params.h" 13 #include "chrome/browser/ui/extensions/app_launch_params.h"
14 #include "chrome/browser/ui/extensions/application_launch.h" 14 #include "chrome/browser/ui/extensions/application_launch.h"
15 #include "chrome/browser/ui/extensions/hosted_app_browser_controller.h" 15 #include "chrome/browser/ui/extensions/hosted_app_browser_controller.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/browser/web_applications/web_app.h" 17 #include "chrome/browser/web_applications/web_app.h"
18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
21 #include "extensions/browser/extension_registry.h" 20 #include "extensions/browser/extension_registry.h"
22 #include "extensions/common/constants.h" 21 #include "extensions/common/constants.h"
23 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
24 #include "extensions/common/extension_set.h" 23 #include "extensions/common/extension_set.h"
25 24
25 #if defined(OS_MACOSX)
26 #include "chrome/common/chrome_features.h"
27 #include "content/public/common/content_switches.h"
28 #endif
29
26 using content::WebContents; 30 using content::WebContents;
27 using extensions::Extension; 31 using extensions::Extension;
28 32
29 namespace { 33 namespace {
30 34
31 // Used by ShouldLocationBarForXXX. Performs a navigation and then checks that 35 // Used by ShouldLocationBarForXXX. Performs a navigation and then checks that
32 // the location bar visibility is as expcted. 36 // the location bar visibility is as expcted.
33 void NavigateAndCheckForLocationBar(Browser* browser, 37 void NavigateAndCheckForLocationBar(Browser* browser,
34 const std::string& url_string, 38 const std::string& url_string,
35 bool expected_visibility) { 39 bool expected_visibility) {
36 GURL url(url_string); 40 GURL url(url_string);
37 ui_test_utils::NavigateToURL(browser, url); 41 ui_test_utils::NavigateToURL(browser, url);
38 EXPECT_EQ(expected_visibility, 42 EXPECT_EQ(expected_visibility,
39 browser->hosted_app_controller()->ShouldShowLocationBar()); 43 browser->hosted_app_controller()->ShouldShowLocationBar());
40 } 44 }
41 45
46 void EnsureBookmarkAppsEnabled() {
47 #if defined(OS_MACOSX)
48 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
49 switches::kEnableFeatures, features::kBookmarkApps.name);
dominickn 2017/03/22 04:18:12 Can you use base::FeatureList::RegisterOverride or
tapted 2017/03/23 02:59:58 Done.
50 #endif
51 }
52
42 } // namespace 53 } // namespace
43 54
44 class HostedAppTest : public ExtensionBrowserTest { 55 class HostedAppTest : public ExtensionBrowserTest {
45 public: 56 public:
46 HostedAppTest() : app_browser_(nullptr) {} 57 HostedAppTest() : app_browser_(nullptr) {}
47 ~HostedAppTest() override {} 58 ~HostedAppTest() override {}
48 59
49 protected: 60 protected:
50 void SetupApp(const std::string& app_folder, bool is_bookmark_app) { 61 void SetupApp(const std::string& app_folder, bool is_bookmark_app) {
51 const Extension* app = InstallExtensionWithSourceAndFlags( 62 const Extension* app = InstallExtensionWithSourceAndFlags(
(...skipping 23 matching lines...) Expand all
75 ASSERT_TRUE(app_browser_); 86 ASSERT_TRUE(app_browser_);
76 ASSERT_TRUE(app_browser_ != browser()); 87 ASSERT_TRUE(app_browser_ != browser());
77 } 88 }
78 89
79 Browser* app_browser_; 90 Browser* app_browser_;
80 }; 91 };
81 92
82 // Check that the location bar is shown correctly for bookmark apps. 93 // Check that the location bar is shown correctly for bookmark apps.
83 IN_PROC_BROWSER_TEST_F(HostedAppTest, 94 IN_PROC_BROWSER_TEST_F(HostedAppTest,
84 ShouldShowLocationBarForBookmarkApp) { 95 ShouldShowLocationBarForBookmarkApp) {
85 base::CommandLine::ForCurrentProcess()->AppendSwitch( 96 EnsureBookmarkAppsEnabled();
86 switches::kEnableNewBookmarkApps);
87 97
88 SetupApp("app", true); 98 SetupApp("app", true);
89 99
90 // Navigate to the app's launch page; the location bar should be hidden. 100 // Navigate to the app's launch page; the location bar should be hidden.
91 NavigateAndCheckForLocationBar( 101 NavigateAndCheckForLocationBar(
92 app_browser_, "http://www.example.com/empty.html", false); 102 app_browser_, "http://www.example.com/empty.html", false);
93 103
94 // Navigate to another page on the same origin; the location bar should still 104 // Navigate to another page on the same origin; the location bar should still
95 // hidden. 105 // hidden.
96 NavigateAndCheckForLocationBar( 106 NavigateAndCheckForLocationBar(
97 app_browser_, "http://www.example.com/blah", false); 107 app_browser_, "http://www.example.com/blah", false);
98 108
99 // Navigate to different origin; the location bar should now be visible. 109 // Navigate to different origin; the location bar should now be visible.
100 NavigateAndCheckForLocationBar( 110 NavigateAndCheckForLocationBar(
101 app_browser_, "http://www.foo.com/blah", true); 111 app_browser_, "http://www.foo.com/blah", true);
102 } 112 }
103 113
104 // Check that the location bar is shown correctly for HTTP bookmark apps when 114 // Check that the location bar is shown correctly for HTTP bookmark apps when
105 // they navigate to a HTTPS page on the same origin. 115 // they navigate to a HTTPS page on the same origin.
106 IN_PROC_BROWSER_TEST_F(HostedAppTest, 116 IN_PROC_BROWSER_TEST_F(HostedAppTest,
107 ShouldShowLocationBarForHTTPBookmarkApp) { 117 ShouldShowLocationBarForHTTPBookmarkApp) {
108 base::CommandLine::ForCurrentProcess()->AppendSwitch( 118 EnsureBookmarkAppsEnabled();
109 switches::kEnableNewBookmarkApps);
110 119
111 SetupApp("app", true); 120 SetupApp("app", true);
112 121
113 // Navigate to the app's launch page; the location bar should be hidden. 122 // Navigate to the app's launch page; the location bar should be hidden.
114 NavigateAndCheckForLocationBar( 123 NavigateAndCheckForLocationBar(
115 app_browser_, "http://www.example.com/empty.html", false); 124 app_browser_, "http://www.example.com/empty.html", false);
116 125
117 // Navigate to the https version of the site; the location bar should 126 // Navigate to the https version of the site; the location bar should
118 // be hidden. 127 // be hidden.
119 NavigateAndCheckForLocationBar( 128 NavigateAndCheckForLocationBar(
120 app_browser_, "https://www.example.com/blah", false); 129 app_browser_, "https://www.example.com/blah", false);
121 } 130 }
122 131
123 // Check that the location bar is shown correctly for HTTPS bookmark apps when 132 // Check that the location bar is shown correctly for HTTPS bookmark apps when
124 // they navigate to a HTTP page on the same origin. 133 // they navigate to a HTTP page on the same origin.
125 IN_PROC_BROWSER_TEST_F(HostedAppTest, 134 IN_PROC_BROWSER_TEST_F(HostedAppTest,
126 ShouldShowLocationBarForHTTPSBookmarkApp) { 135 ShouldShowLocationBarForHTTPSBookmarkApp) {
127 base::CommandLine::ForCurrentProcess()->AppendSwitch( 136 EnsureBookmarkAppsEnabled();
128 switches::kEnableNewBookmarkApps);
129 137
130 SetupApp("https_app", true); 138 SetupApp("https_app", true);
131 139
132 // Navigate to the app's launch page; the location bar should be hidden. 140 // Navigate to the app's launch page; the location bar should be hidden.
133 NavigateAndCheckForLocationBar( 141 NavigateAndCheckForLocationBar(
134 app_browser_, "https://www.example.com/empty.html", false); 142 app_browser_, "https://www.example.com/empty.html", false);
135 143
136 // Navigate to the http version of the site; the location bar should 144 // Navigate to the http version of the site; the location bar should
137 // be visible for the https version as it is now on a less secure version 145 // be visible for the https version as it is now on a less secure version
138 // of its host. 146 // of its host.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 179
172 // Navigate to the app's launch page with the 'www.' prefis; the location bar 180 // Navigate to the app's launch page with the 'www.' prefis; the location bar
173 // should be hidden. 181 // should be hidden.
174 NavigateAndCheckForLocationBar( 182 NavigateAndCheckForLocationBar(
175 app_browser_, "http://www.example.com/empty.html", false); 183 app_browser_, "http://www.example.com/empty.html", false);
176 184
177 // Navigate to different origin; the location bar should now be visible. 185 // Navigate to different origin; the location bar should now be visible.
178 NavigateAndCheckForLocationBar( 186 NavigateAndCheckForLocationBar(
179 app_browser_, "http://www.foo.com/blah", true); 187 app_browser_, "http://www.foo.com/blah", true);
180 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698