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

Side by Side Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 10436015: Remove chrome.windows.* support for platform apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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
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 "chrome/browser/automation/automation_util.h" 5 #include "chrome/browser/automation/automation_util.h"
6 #include "chrome/browser/tab_contents/render_view_context_menu.h" 6 #include "chrome/browser/tab_contents/render_view_context_menu.h"
7 #include "chrome/browser/extensions/extension_test_message_listener.h" 7 #include "chrome/browser/extensions/extension_test_message_listener.h"
8 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 8 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
9 #include "chrome/browser/extensions/shell_window_registry.h" 9 #include "chrome/browser/extensions/shell_window_registry.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // extensions API. 143 // extensions API.
144 const Extension* extension = LoadExtension( 144 const Extension* extension = LoadExtension(
145 test_data_dir_.AppendASCII("common/background_page")); 145 test_data_dir_.AppendASCII("common/background_page"));
146 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension)); 146 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension));
147 147
148 // And no shell windows. 148 // And no shell windows.
149 ASSERT_EQ(0U, GetShellWindowCount()); 149 ASSERT_EQ(0U, GetShellWindowCount());
150 150
151 // Launch a platform app that shows a window. 151 // Launch a platform app that shows a window.
152 ExtensionTestMessageListener launched_listener("Launched", false); 152 ExtensionTestMessageListener launched_listener("Launched", false);
153 const Extension* platform_app = LoadAndLaunchPlatformApp("minimal"); 153 LoadAndLaunchPlatformApp("minimal");
154 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 154 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
155 ASSERT_EQ(1U, GetShellWindowCount()); 155 ASSERT_EQ(1U, GetShellWindowCount());
156 ShellWindowRegistry::ShellWindowSet shell_windows = 156 ShellWindowRegistry::ShellWindowSet shell_windows =
157 ShellWindowRegistry::Get(browser()->profile())->shell_windows(); 157 ShellWindowRegistry::Get(browser()->profile())->shell_windows();
158 int shell_window_id = (*shell_windows.begin())->session_id().id(); 158 int shell_window_id = (*shell_windows.begin())->session_id().id();
159 159
160 // But it's not visible to the extensions API, it still thinks there's just 160 // But it's not visible to the extensions API, it still thinks there's just
161 // one browser window. 161 // one browser window.
162 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension)); 162 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension));
163 // It can't look it up by ID either 163 // It can't look it up by ID either
164 ASSERT_FALSE(RunGetWindowFunctionForExtension(shell_window_id, extension)); 164 ASSERT_FALSE(RunGetWindowFunctionForExtension(shell_window_id, extension));
165 165
166 // The app can also only see one window (its own). 166 // The app can also only see one window (its own).
167 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(platform_app)); 167 // TODO(jeremya): add an extension function to get a shell window by ID, and
168 ASSERT_TRUE(RunGetWindowFunctionForExtension(shell_window_id, platform_app)); 168 // to get a list of all the shell windows, so we can test this.
169 169
170 // Launch another platform app that also shows a window. 170 // Launch another platform app that also shows a window.
171 ExtensionTestMessageListener launched_listener2("Launched", false); 171 ExtensionTestMessageListener launched_listener2("Launched", false);
172 const Extension* platform_app2 = LoadAndLaunchPlatformApp("context_menu"); 172 LoadAndLaunchPlatformApp("context_menu");
173 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); 173 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
174 174
175 // There are two total shell windows, but each app can only see its own. 175 // There are two total shell windows, but each app can only see its own.
176 ASSERT_EQ(2U, GetShellWindowCount()); 176 ASSERT_EQ(2U, GetShellWindowCount());
177 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(platform_app)); 177 // TODO(jeremya): as above, this requires more extension functions.
178 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(platform_app2));
179 } 178 }
180 179
181 // TODO(benwells): fix these tests for ChromeOS. 180 // TODO(benwells): fix these tests for ChromeOS.
182 #if !defined(OS_CHROMEOS) 181 #if !defined(OS_CHROMEOS)
183 // Tests that command line parameters get passed through to platform apps 182 // Tests that command line parameters get passed through to platform apps
184 // via launchData correctly when launching with a file. 183 // via launchData correctly when launching with a file.
185 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) { 184 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) {
186 SetCommandLineArg( "platform_apps/launch_files/test.txt"); 185 SetCommandLineArg( "platform_apps/launch_files/test.txt");
187 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_file")) 186 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_file"))
188 << message_; 187 << message_;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 234 }
236 235
237 // Tests that no launch data is sent through if there are no arguments passed 236 // Tests that no launch data is sent through if there are no arguments passed
238 // on the command line 237 // on the command line
239 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNothing) { 238 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNothing) {
240 ClearCommandLineArgs(); 239 ClearCommandLineArgs();
241 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_nothing")) 240 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_nothing"))
242 << message_; 241 << message_;
243 } 242 }
244 #endif // defined(OS_CHROMEOS) 243 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tabs_module_constants.cc ('k') | chrome/browser/ui/extensions/shell_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698