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

Side by Side Diff: chrome/browser/extensions/api/management/management_apitest.cc

Issue 10836301: Make apps with launch container type panel open as popups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 8 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/extensions/application_launch.cc » ('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) 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 <map> 5 #include <map>
6 6
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/extensions/extension_test_message_listener.h" 10 #include "chrome/browser/extensions/extension_test_message_listener.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 ExtensionTestMessageListener launcher_loaded("launcher loaded", false); 158 ExtensionTestMessageListener launcher_loaded("launcher loaded", false);
159 ASSERT_TRUE(LoadExtension( 159 ASSERT_TRUE(LoadExtension(
160 test_data_dir_.AppendASCII("management/launch_on_install"))); 160 test_data_dir_.AppendASCII("management/launch_on_install")));
161 ASSERT_TRUE(launcher_loaded.WaitUntilSatisfied()); 161 ASSERT_TRUE(launcher_loaded.WaitUntilSatisfied());
162 162
163 // Load an app with app.launch.container = "panel". 163 // Load an app with app.launch.container = "panel".
164 std::string app_id; 164 std::string app_id;
165 LoadAndWaitForLaunch("management/launch_app_panel", &app_id); 165 LoadAndWaitForLaunch("management/launch_app_panel", &app_id);
166 ASSERT_FALSE(HasFatalFailure()); // Stop the test if any ASSERT failed. 166 ASSERT_FALSE(HasFatalFailure()); // Stop the test if any ASSERT failed.
167 167
168 // Find the app's browser. Check that it is a panel. 168 // Find the app's browser. Check that it is a popup.
169 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); 169 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile()));
170 Browser* app_browser = FindOtherBrowser(browser()); 170 Browser* app_browser = FindOtherBrowser(browser());
171 ASSERT_TRUE(app_browser->is_type_panel()); 171 ASSERT_TRUE(app_browser->is_type_popup());
172 ASSERT_TRUE(app_browser->is_app()); 172 ASSERT_TRUE(app_browser->is_app());
173 173
174 // Close the app panel. 174 // Close the app panel.
175 content::WindowedNotificationObserver signal( 175 content::WindowedNotificationObserver signal(
176 chrome::NOTIFICATION_BROWSER_CLOSED, 176 chrome::NOTIFICATION_BROWSER_CLOSED,
177 content::Source<Browser>(app_browser)); 177 content::Source<Browser>(app_browser));
178 178
179 chrome::CloseWindow(app_browser); 179 chrome::CloseWindow(app_browser);
180 signal.Wait(); 180 signal.Wait();
181 181
182 // Unload the extension. 182 // Unload the extension.
183 UninstallExtension(app_id); 183 UninstallExtension(app_id);
184 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); 184 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile()));
185 ASSERT_FALSE(service->GetExtensionById(app_id, true)); 185 ASSERT_FALSE(service->GetExtensionById(app_id, true));
186 186
187 // Set a pref indicating that the user wants to launch in a regular tab. 187 // Set a pref indicating that the user wants to launch in a regular tab.
188 // This should be ignored, because panel apps always load in a panel. 188 // This should be ignored, because panel apps always load in a popup.
189 service->extension_prefs()->SetLaunchType( 189 service->extension_prefs()->SetLaunchType(
190 app_id, extensions::ExtensionPrefs::LAUNCH_REGULAR); 190 app_id, extensions::ExtensionPrefs::LAUNCH_REGULAR);
191 191
192 // Load the extension again. 192 // Load the extension again.
193 std::string app_id_new; 193 std::string app_id_new;
194 LoadAndWaitForLaunch("management/launch_app_panel", &app_id_new); 194 LoadAndWaitForLaunch("management/launch_app_panel", &app_id_new);
195 ASSERT_FALSE(HasFatalFailure()); 195 ASSERT_FALSE(HasFatalFailure());
196 196
197 // If the ID changed, then the pref will not apply to the app. 197 // If the ID changed, then the pref will not apply to the app.
198 ASSERT_EQ(app_id, app_id_new); 198 ASSERT_EQ(app_id, app_id_new);
199 199
200 // Find the app's browser. Apps that should load in a panel ignore 200 // Find the app's browser. Apps that should load in a panel ignore
201 // prefs, so we should still see the launch in a panel. 201 // prefs, so we should still see the launch in a popup.
202 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); 202 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile()));
203 app_browser = FindOtherBrowser(browser()); 203 app_browser = FindOtherBrowser(browser());
204 ASSERT_TRUE(app_browser->is_type_panel()); 204 ASSERT_TRUE(app_browser->is_type_popup());
205 ASSERT_TRUE(app_browser->is_app()); 205 ASSERT_TRUE(app_browser->is_app());
206 } 206 }
207 207
208 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) { 208 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) {
209 ExtensionService* service = browser()->profile()->GetExtensionService(); 209 ExtensionService* service = browser()->profile()->GetExtensionService();
210 210
211 // Load an extension that calls launchApp() on any app that gets 211 // Load an extension that calls launchApp() on any app that gets
212 // installed. 212 // installed.
213 ExtensionTestMessageListener launcher_loaded("launcher loaded", false); 213 ExtensionTestMessageListener launcher_loaded("launcher loaded", false);
214 ASSERT_TRUE(LoadExtension( 214 ASSERT_TRUE(LoadExtension(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 ASSERT_EQ(2, browser()->tab_count()); 252 ASSERT_EQ(2, browser()->tab_count());
253 #else 253 #else
254 // Find the app's browser. Opening in a new window will create 254 // Find the app's browser. Opening in a new window will create
255 // a new browser. 255 // a new browser.
256 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); 256 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile()));
257 Browser* app_browser = FindOtherBrowser(browser()); 257 Browser* app_browser = FindOtherBrowser(browser());
258 ASSERT_TRUE(app_browser->is_app()); 258 ASSERT_TRUE(app_browser->is_app());
259 ASSERT_FALSE(app_browser->is_type_panel()); 259 ASSERT_FALSE(app_browser->is_type_panel());
260 #endif 260 #endif
261 } 261 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/extensions/application_launch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698