| OLD | NEW |
| 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/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 ash::Launcher* launcher_; | 122 ash::Launcher* launcher_; |
| 123 ash::LauncherModel* model_; | 123 ash::LauncherModel* model_; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 // Test that we can launch a platform app and get a running item. | 126 // Test that we can launch a platform app and get a running item. |
| 127 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { | 127 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { |
| 128 ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay(); | 128 ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay(); |
| 129 int item_count = launcher->model()->item_count(); | 129 int item_count = launcher->model()->item_count(); |
| 130 const Extension* extension = LoadPlatformApp("launch"); | 130 const Extension* extension = LoadAndLaunchPlatformApp("launch"); |
| 131 ShellWindow* window = CreateShellWindow(extension); | 131 ShellWindow* window = CreateShellWindow(extension); |
| 132 ++item_count; | 132 ++item_count; |
| 133 ASSERT_EQ(item_count, launcher->model()->item_count()); | 133 ASSERT_EQ(item_count, launcher->model()->item_count()); |
| 134 ash::LauncherItem item = | 134 ash::LauncherItem item = |
| 135 launcher->model()->items()[launcher->model()->item_count() - 2]; | 135 launcher->model()->items()[launcher->model()->item_count() - 2]; |
| 136 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 136 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
| 137 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 137 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
| 138 CloseShellWindow(window); | 138 CloseShellWindow(window); |
| 139 --item_count; | 139 --item_count; |
| 140 EXPECT_EQ(item_count, launcher->model()->item_count()); | 140 EXPECT_EQ(item_count, launcher->model()->item_count()); |
| 141 CloseShellWindowsAndWaitForAppToExit(); | |
| 142 } | 141 } |
| 143 | 142 |
| 144 // Test that we can launch a platform app that already has a shortcut. | 143 // Test that we can launch a platform app that already has a shortcut. |
| 145 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { | 144 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { |
| 146 int item_count = launcher_->model()->item_count(); | 145 int item_count = launcher_->model()->item_count(); |
| 147 | 146 |
| 148 // First get app_id. | 147 // First get app_id. |
| 149 const Extension* extension = LoadPlatformApp("launch"); | 148 const Extension* extension = LoadAndLaunchPlatformApp("launch"); |
| 150 const std::string app_id = extension->id(); | 149 const std::string app_id = extension->id(); |
| 151 | 150 |
| 152 // Then create a shortcut. | 151 // Then create a shortcut. |
| 153 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); | 152 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); |
| 154 ++item_count; | 153 ++item_count; |
| 155 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 154 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 156 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); | 155 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); |
| 157 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 156 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
| 158 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 157 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 159 | 158 |
| 160 // Open a window. Confirm the item is now running. | 159 // Open a window. Confirm the item is now running. |
| 161 ShellWindow* window = CreateShellWindow(extension); | 160 ShellWindow* window = CreateShellWindow(extension); |
| 162 ash::wm::ActivateWindow(window->GetNativeWindow()); | 161 ash::wm::ActivateWindow(window->GetNativeWindow()); |
| 163 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 162 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 164 item = *launcher_->model()->ItemByID(shortcut_id); | 163 item = *launcher_->model()->ItemByID(shortcut_id); |
| 165 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 164 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
| 166 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 165 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
| 167 | 166 |
| 168 // Then close it, make sure there's still an item. | 167 // Then close it, make sure there's still an item. |
| 169 CloseShellWindow(window); | 168 CloseShellWindow(window); |
| 170 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 169 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 171 item = *launcher_->model()->ItemByID(shortcut_id); | 170 item = *launcher_->model()->ItemByID(shortcut_id); |
| 172 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 171 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
| 173 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 172 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 174 CloseShellWindowsAndWaitForAppToExit(); | |
| 175 } | 173 } |
| 176 | 174 |
| 177 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { | 175 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { |
| 178 // Run. | 176 // Run. |
| 179 int item_count = launcher_->model()->item_count(); | 177 int item_count = launcher_->model()->item_count(); |
| 180 const Extension* extension = LoadPlatformApp("launch"); | 178 const Extension* extension = LoadAndLaunchPlatformApp("launch"); |
| 181 ShellWindow* window = CreateShellWindow(extension); | 179 ShellWindow* window = CreateShellWindow(extension); |
| 182 ++item_count; | 180 ++item_count; |
| 183 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 181 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 184 ash::LauncherItem item = | 182 ash::LauncherItem item = |
| 185 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 183 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
| 186 ash::LauncherID id = item.id; | 184 ash::LauncherID id = item.id; |
| 187 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 185 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
| 188 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 186 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
| 189 | 187 |
| 190 // Create a shortcut. The app item should be after it. | 188 // Create a shortcut. The app item should be after it. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 204 // New shortcuts should come after the item. | 202 // New shortcuts should come after the item. |
| 205 ash::LauncherID bar_id = CreateAppShortcutLauncherItem("bar"); | 203 ash::LauncherID bar_id = CreateAppShortcutLauncherItem("bar"); |
| 206 ++item_count; | 204 ++item_count; |
| 207 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 205 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 208 EXPECT_LT(launcher_->model()->ItemIndexByID(id), | 206 EXPECT_LT(launcher_->model()->ItemIndexByID(id), |
| 209 launcher_->model()->ItemIndexByID(bar_id)); | 207 launcher_->model()->ItemIndexByID(bar_id)); |
| 210 | 208 |
| 211 // Then close it, make sure the item remains. | 209 // Then close it, make sure the item remains. |
| 212 CloseShellWindow(window); | 210 CloseShellWindow(window); |
| 213 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 211 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 214 CloseShellWindowsAndWaitForAppToExit(); | |
| 215 } | 212 } |
| 216 | 213 |
| 217 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { | 214 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { |
| 218 int item_count = launcher_->model()->item_count(); | 215 int item_count = launcher_->model()->item_count(); |
| 219 | 216 |
| 220 // First get app_id. | 217 // First get app_id. |
| 221 const Extension* extension = LoadPlatformApp("launch"); | 218 const Extension* extension = LoadAndLaunchPlatformApp("launch"); |
| 222 const std::string app_id = extension->id(); | 219 const std::string app_id = extension->id(); |
| 223 | 220 |
| 224 // Then create a shortcut. | 221 // Then create a shortcut. |
| 225 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); | 222 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); |
| 226 ++item_count; | 223 ++item_count; |
| 227 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 224 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 228 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); | 225 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); |
| 229 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 226 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
| 230 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 227 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 231 | 228 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 252 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 249 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
| 253 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 250 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
| 254 // The item should have moved after the other shortcuts. | 251 // The item should have moved after the other shortcuts. |
| 255 EXPECT_GT(launcher_->model()->ItemIndexByID(shortcut_id), | 252 EXPECT_GT(launcher_->model()->ItemIndexByID(shortcut_id), |
| 256 launcher_->model()->ItemIndexByID(foo_id)); | 253 launcher_->model()->ItemIndexByID(foo_id)); |
| 257 | 254 |
| 258 // Then close it, make sure the item's gone. | 255 // Then close it, make sure the item's gone. |
| 259 CloseShellWindow(window); | 256 CloseShellWindow(window); |
| 260 --item_count; | 257 --item_count; |
| 261 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 258 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 262 CloseShellWindowsAndWaitForAppToExit(); | |
| 263 } | 259 } |
| 264 | 260 |
| 265 // Test that we can launch a platform app with more than one window. | 261 // Test that we can launch a platform app with more than one window. |
| 266 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { | 262 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { |
| 267 int item_count = launcher_->model()->item_count(); | 263 int item_count = launcher_->model()->item_count(); |
| 268 | 264 |
| 269 // First run app. | 265 // First run app. |
| 270 const Extension* extension = LoadPlatformApp("launch"); | 266 const Extension* extension = LoadAndLaunchPlatformApp("launch"); |
| 271 ShellWindow* window1 = CreateShellWindow(extension); | 267 ShellWindow* window1 = CreateShellWindow(extension); |
| 272 ++item_count; | 268 ++item_count; |
| 273 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 269 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 274 ash::LauncherItem item = | 270 ash::LauncherItem item = |
| 275 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 271 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
| 276 ash::LauncherID item_id = item.id; | 272 ash::LauncherID item_id = item.id; |
| 277 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 273 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
| 278 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 274 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
| 279 | 275 |
| 280 // Add second window. | 276 // Add second window. |
| 281 ShellWindow* window2 = CreateShellWindow(extension); | 277 ShellWindow* window2 = CreateShellWindow(extension); |
| 282 // Confirm item stays. | 278 // Confirm item stays. |
| 283 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 279 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 284 item = *launcher_->model()->ItemByID(item_id); | 280 item = *launcher_->model()->ItemByID(item_id); |
| 285 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 281 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
| 286 | 282 |
| 287 // Close second window. | 283 // Close second window. |
| 288 CloseShellWindow(window2); | 284 CloseShellWindow(window2); |
| 289 // Confirm item stays. | 285 // Confirm item stays. |
| 290 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 286 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 291 item = *launcher_->model()->ItemByID(item_id); | 287 item = *launcher_->model()->ItemByID(item_id); |
| 292 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 288 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
| 293 | 289 |
| 294 // Close first window. | 290 // Close first window. |
| 295 CloseShellWindow(window1); | 291 CloseShellWindow(window1); |
| 296 // Confirm item is removed. | 292 // Confirm item is removed. |
| 297 --item_count; | 293 --item_count; |
| 298 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 294 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 299 CloseShellWindowsAndWaitForAppToExit(); | |
| 300 } | 295 } |
| 301 | 296 |
| 302 // Times out on ChromeOS: http://crbug.com/159394 | 297 // Times out on ChromeOS: http://crbug.com/159394 |
| 303 #if defined(OS_CHROMEOS) | 298 #if defined(OS_CHROMEOS) |
| 304 #define MAYBE_MultipleApps DISABLED_MultipleApps | 299 #define MAYBE_MultipleApps DISABLED_MultipleApps |
| 305 #else | 300 #else |
| 306 #define MAYBE_MultipleApps MultipleApps | 301 #define MAYBE_MultipleApps MultipleApps |
| 307 #endif | 302 #endif |
| 308 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_MultipleApps) { | 303 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_MultipleApps) { |
| 309 int item_count = launcher_->model()->item_count(); | 304 int item_count = launcher_->model()->item_count(); |
| 310 | 305 |
| 311 // First run app. | 306 // First run app. |
| 312 const Extension* extension1 = LoadPlatformApp("launch"); | 307 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); |
| 313 ShellWindow* window1 = CreateShellWindow(extension1); | 308 ShellWindow* window1 = CreateShellWindow(extension1); |
| 314 ++item_count; | 309 ++item_count; |
| 315 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 310 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 316 ash::LauncherItem item1 = | 311 ash::LauncherItem item1 = |
| 317 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 312 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
| 318 ash::LauncherID item_id1 = item1.id; | 313 ash::LauncherID item_id1 = item1.id; |
| 319 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 314 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
| 320 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 315 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
| 321 | 316 |
| 322 // Then run second app. | 317 // Then run second app. |
| 323 const Extension* extension2 = LoadPlatformApp("launch_2"); | 318 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); |
| 324 ShellWindow* window2 = CreateShellWindow(extension2); | 319 ShellWindow* window2 = CreateShellWindow(extension2); |
| 325 ++item_count; | 320 ++item_count; |
| 326 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 321 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 327 ash::LauncherItem item2 = | 322 ash::LauncherItem item2 = |
| 328 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 323 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
| 329 ash::LauncherID item_id2 = item2.id; | 324 ash::LauncherID item_id2 = item2.id; |
| 330 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); | 325 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); |
| 331 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 326 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
| 332 | 327 |
| 333 EXPECT_NE(item_id1, item_id2); | 328 EXPECT_NE(item_id1, item_id2); |
| 334 EXPECT_EQ(ash::STATUS_RUNNING, | 329 EXPECT_EQ(ash::STATUS_RUNNING, |
| 335 launcher_->model()->ItemByID(item_id1)->status); | 330 launcher_->model()->ItemByID(item_id1)->status); |
| 336 | 331 |
| 337 // Close second app. | 332 // Close second app. |
| 338 CloseShellWindow(window2); | 333 CloseShellWindow(window2); |
| 339 --item_count; | 334 --item_count; |
| 340 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 335 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 341 // First app should be active again. | 336 // First app should be active again. |
| 342 EXPECT_EQ(ash::STATUS_ACTIVE, | 337 EXPECT_EQ(ash::STATUS_ACTIVE, |
| 343 launcher_->model()->ItemByID(item_id1)->status); | 338 launcher_->model()->ItemByID(item_id1)->status); |
| 344 | 339 |
| 345 // Close first app. | 340 // Close first app. |
| 346 CloseShellWindow(window1); | 341 CloseShellWindow(window1); |
| 347 --item_count; | 342 --item_count; |
| 348 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 343 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 349 CloseShellWindowsAndWaitForAppToExit(); | 344 |
| 350 } | 345 } |
| 351 | 346 |
| 352 // Confirm that app windows can be reactivated by clicking their icons and that | 347 // Confirm that app windows can be reactivated by clicking their icons and that |
| 353 // the correct activation order is maintained. | 348 // the correct activation order is maintained. |
| 354 // Times out on ChromeOS: http://crbug.com/159394 | 349 // Times out on ChromeOS: http://crbug.com/159394 |
| 355 #if defined(OS_CHROMEOS) | 350 #if defined(OS_CHROMEOS) |
| 356 #define MAYBE_WindowActivation DISABLED_WindowActivation | 351 #define MAYBE_WindowActivation DISABLED_WindowActivation |
| 357 #else | 352 #else |
| 358 #define MAYBE_WindowActivation WindowActivation | 353 #define MAYBE_WindowActivation WindowActivation |
| 359 #endif | 354 #endif |
| 360 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) { | 355 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) { |
| 361 int item_count = launcher_->model()->item_count(); | 356 int item_count = launcher_->model()->item_count(); |
| 362 | 357 |
| 363 // First run app. | 358 // First run app. |
| 364 const Extension* extension1 = LoadPlatformApp("launch"); | 359 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); |
| 365 ShellWindow* window1 = CreateShellWindow(extension1); | 360 ShellWindow* window1 = CreateShellWindow(extension1); |
| 366 ++item_count; | 361 ++item_count; |
| 367 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 362 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 368 ash::LauncherItem item1 = | 363 ash::LauncherItem item1 = |
| 369 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 364 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
| 370 ash::LauncherID item_id1 = item1.id; | 365 ash::LauncherID item_id1 = item1.id; |
| 371 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 366 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
| 372 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 367 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
| 373 | 368 |
| 374 // Then run second app. | 369 // Then run second app. |
| 375 const Extension* extension2 = LoadPlatformApp("launch_2"); | 370 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); |
| 376 ShellWindow* window2 = CreateShellWindow(extension2); | 371 ShellWindow* window2 = CreateShellWindow(extension2); |
| 377 ++item_count; | 372 ++item_count; |
| 378 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 373 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 379 ash::LauncherItem item2 = | 374 ash::LauncherItem item2 = |
| 380 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 375 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
| 381 ash::LauncherID item_id2 = item2.id; | 376 ash::LauncherID item_id2 = item2.id; |
| 382 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); | 377 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); |
| 383 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 378 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
| 384 | 379 |
| 385 EXPECT_NE(item_id1, item_id2); | 380 EXPECT_NE(item_id1, item_id2); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 --item_count; | 429 --item_count; |
| 435 EXPECT_EQ(item_count, launcher_->model()->item_count()); | 430 EXPECT_EQ(item_count, launcher_->model()->item_count()); |
| 436 // First app should be active again. | 431 // First app should be active again. |
| 437 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status); | 432 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status); |
| 438 | 433 |
| 439 // Close first app. | 434 // Close first app. |
| 440 CloseShellWindow(window1b); | 435 CloseShellWindow(window1b); |
| 441 CloseShellWindow(window1); | 436 CloseShellWindow(window1); |
| 442 --item_count; | 437 --item_count; |
| 443 EXPECT_EQ(item_count, launcher_->model()->item_count()); | 438 EXPECT_EQ(item_count, launcher_->model()->item_count()); |
| 444 CloseShellWindowsAndWaitForAppToExit(); | |
| 445 } | 439 } |
| 446 | 440 |
| 447 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { | 441 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { |
| 448 int item_count = launcher_->model()->item_count(); | 442 int item_count = launcher_->model()->item_count(); |
| 449 | 443 |
| 450 // First run app. | 444 // First run app. |
| 451 const Extension* extension1 = LoadPlatformApp("launch"); | 445 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); |
| 452 CreateShellWindow(extension1); | 446 CreateShellWindow(extension1); |
| 453 ++item_count; | 447 ++item_count; |
| 454 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 448 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 455 ash::LauncherItem item1 = | 449 ash::LauncherItem item1 = |
| 456 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 450 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
| 457 ash::LauncherID item_id1 = item1.id; | 451 ash::LauncherID item_id1 = item1.id; |
| 458 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 452 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
| 459 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 453 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
| 460 | 454 |
| 461 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); | 455 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); |
| 462 EXPECT_EQ(ash::STATUS_RUNNING, | 456 EXPECT_EQ(ash::STATUS_RUNNING, |
| 463 launcher_->model()->ItemByID(item_id1)->status); | 457 launcher_->model()->ItemByID(item_id1)->status); |
| 464 CloseShellWindowsAndWaitForAppToExit(); | |
| 465 } | 458 } |
| 466 | 459 |
| 467 // Test that we can launch an app with a shortcut. | 460 // Test that we can launch an app with a shortcut. |
| 468 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { | 461 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { |
| 469 TabStripModel* tab_strip = browser()->tab_strip_model(); | 462 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 470 int tab_count = tab_strip->count(); | 463 int tab_count = tab_strip->count(); |
| 471 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 464 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
| 472 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 465 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
| 473 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 466 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); |
| 474 EXPECT_EQ(++tab_count, tab_strip->count()); | 467 EXPECT_EQ(++tab_count, tab_strip->count()); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 734 |
| 742 // Activating app should launch new tab, because second tab isn't | 735 // Activating app should launch new tab, because second tab isn't |
| 743 // in its refocus url path. | 736 // in its refocus url path. |
| 744 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 737 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); |
| 745 EXPECT_EQ(++tab_count, tab_strip->count()); | 738 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 746 TabContents* second_tab = tab_strip->GetActiveTabContents(); | 739 TabContents* second_tab = tab_strip->GetActiveTabContents(); |
| 747 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 740 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 748 EXPECT_NE(first_tab, second_tab); | 741 EXPECT_NE(first_tab, second_tab); |
| 749 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); | 742 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); |
| 750 } | 743 } |
| OLD | NEW |