OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/common/shelf/shelf_delegate.h" | 5 #include "ash/common/shelf/shelf_delegate.h" |
6 #include "ash/common/wm_shell.h" | 6 #include "ash/common/wm_shell.h" |
7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 static arc::mojom::ShortcutInfoPtr Convert( | 46 static arc::mojom::ShortcutInfoPtr Convert( |
47 const arc::mojom::ShortcutInfo& shortcut_info) { | 47 const arc::mojom::ShortcutInfo& shortcut_info) { |
48 return shortcut_info.Clone(); | 48 return shortcut_info.Clone(); |
49 } | 49 } |
50 }; | 50 }; |
51 | 51 |
52 } // namespace mojo | 52 } // namespace mojo |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 constexpr char kTestAppName[] = "Test Arc App"; | 56 constexpr char kTestAppName[] = "Test ARC App"; |
57 constexpr char kTestAppName2[] = "Test Arc App 2"; | 57 constexpr char kTestAppName2[] = "Test ARC App 2"; |
58 constexpr char kTestShortcutName[] = "Test Shortcut"; | 58 constexpr char kTestShortcutName[] = "Test Shortcut"; |
59 constexpr char kTestShortcutName2[] = "Test Shortcut 2"; | 59 constexpr char kTestShortcutName2[] = "Test Shortcut 2"; |
60 constexpr char kTestAppPackage[] = "test.arc.app.package"; | 60 constexpr char kTestAppPackage[] = "test.arc.app.package"; |
61 constexpr char kTestAppPackage2[] = "test.arc.app.package2"; | 61 constexpr char kTestAppPackage2[] = "test.arc.app.package2"; |
62 constexpr char kTestAppPackage3[] = "test.arc.app.package3"; | 62 constexpr char kTestAppPackage3[] = "test.arc.app.package3"; |
63 constexpr char kTestAppActivity[] = "test.arc.app.package.activity"; | 63 constexpr char kTestAppActivity[] = "test.arc.app.package.activity"; |
64 constexpr char kTestAppActivity2[] = "test.arc.gitapp.package.activity2"; | 64 constexpr char kTestAppActivity2[] = "test.arc.gitapp.package.activity2"; |
65 constexpr char kTestShelfGroup[] = "shelf_group"; | 65 constexpr char kTestShelfGroup[] = "shelf_group"; |
66 constexpr char kTestShelfGroup2[] = "shelf_group_2"; | 66 constexpr char kTestShelfGroup2[] = "shelf_group_2"; |
67 constexpr char kTestShelfGroup3[] = "shelf_group_3"; | 67 constexpr char kTestShelfGroup3[] = "shelf_group_3"; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 289 |
290 protected: | 290 protected: |
291 bool is_pinned() const { return std::tr1::get<1>(GetParam()); } | 291 bool is_pinned() const { return std::tr1::get<1>(GetParam()); } |
292 | 292 |
293 TestAction test_action() const { return std::tr1::get<0>(GetParam()); } | 293 TestAction test_action() const { return std::tr1::get<0>(GetParam()); } |
294 | 294 |
295 private: | 295 private: |
296 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherBrowserTest); | 296 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherBrowserTest); |
297 }; | 297 }; |
298 | 298 |
299 // This tests simulates normal workflow for starting Arc app in deferred mode. | 299 // This tests simulates normal workflow for starting ARC app in deferred mode. |
300 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) { | 300 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) { |
301 // Install app to remember existing apps. | 301 // Install app to remember existing apps. |
302 StartInstance(); | 302 StartInstance(); |
303 InstallTestApps(kTestAppPackage, false); | 303 InstallTestApps(kTestAppPackage, false); |
304 SendPackageAdded(kTestAppPackage, false); | 304 SendPackageAdded(kTestAppPackage, false); |
305 | 305 |
306 const std::string app_id = GetTestApp1Id(kTestAppPackage); | 306 const std::string app_id = GetTestApp1Id(kTestAppPackage); |
307 if (is_pinned()) { | 307 if (is_pinned()) { |
308 shelf_delegate()->PinAppWithID(app_id); | 308 shelf_delegate()->PinAppWithID(app_id); |
309 const ash::ShelfID shelf_id = shelf_delegate()->GetShelfIDForAppID(app_id); | 309 const ash::ShelfID shelf_id = shelf_delegate()->GetShelfIDForAppID(app_id); |
(...skipping 13 matching lines...) Expand all Loading... |
323 // currently. | 323 // currently. |
324 StartInstance(); | 324 StartInstance(); |
325 app_info = app_prefs()->GetApp(app_id); | 325 app_info = app_prefs()->GetApp(app_id); |
326 ASSERT_TRUE(app_info); | 326 ASSERT_TRUE(app_info); |
327 EXPECT_FALSE(app_info->ready); | 327 EXPECT_FALSE(app_info->ready); |
328 if (is_pinned()) | 328 if (is_pinned()) |
329 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 329 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
330 else | 330 else |
331 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 331 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
332 | 332 |
333 // Launching non-ready Arc app creates item on shelf and spinning animation. | 333 // Launching non-ready ARC app creates item on shelf and spinning animation. |
334 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); | 334 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); |
335 const ash::ShelfID shelf_id = shelf_delegate()->GetShelfIDForAppID(app_id); | 335 const ash::ShelfID shelf_id = shelf_delegate()->GetShelfIDForAppID(app_id); |
336 EXPECT_TRUE(shelf_id); | 336 EXPECT_TRUE(shelf_id); |
337 const ash::ShelfItem* item = chrome_controller()->GetItem(shelf_id); | 337 const ash::ShelfItem* item = chrome_controller()->GetItem(shelf_id); |
338 EXPECT_EQ(base::UTF8ToUTF16(kTestAppName), item->title); | 338 EXPECT_EQ(base::UTF8ToUTF16(kTestAppName), item->title); |
339 AppAnimatedWaiter(app_id).Wait(); | 339 AppAnimatedWaiter(app_id).Wait(); |
340 | 340 |
341 switch (test_action()) { | 341 switch (test_action()) { |
342 case TEST_ACTION_START: | 342 case TEST_ACTION_START: |
343 // Now simulates that Arc is started and app list is refreshed. This | 343 // Now simulates that ARC is started and app list is refreshed. This |
344 // should stop animation and delete icon from the shelf. | 344 // should stop animation and delete icon from the shelf. |
345 InstallTestApps(kTestAppPackage, false); | 345 InstallTestApps(kTestAppPackage, false); |
346 SendPackageAdded(kTestAppPackage, false); | 346 SendPackageAdded(kTestAppPackage, false); |
347 EXPECT_TRUE(chrome_controller() | 347 EXPECT_TRUE(chrome_controller() |
348 ->GetArcDeferredLauncher() | 348 ->GetArcDeferredLauncher() |
349 ->GetActiveTime(app_id) | 349 ->GetActiveTime(app_id) |
350 .is_zero()); | 350 .is_zero()); |
351 if (is_pinned()) | 351 if (is_pinned()) |
352 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 352 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
353 else | 353 else |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 452 |
453 // Run next installation batch. App list should be shown again. | 453 // Run next installation batch. App list should be shown again. |
454 SendInstallationStarted(kTestAppPackage3); | 454 SendInstallationStarted(kTestAppPackage3); |
455 SendInstallationFinished(kTestAppPackage3, true); | 455 SendInstallationFinished(kTestAppPackage3, true); |
456 InstallTestApps(kTestAppPackage3, false); | 456 InstallTestApps(kTestAppPackage3, false); |
457 SendPackageAdded(kTestAppPackage3, true); | 457 SendPackageAdded(kTestAppPackage3, true); |
458 EXPECT_TRUE(app_list_service->IsAppListVisible()); | 458 EXPECT_TRUE(app_list_service->IsAppListVisible()); |
459 app_list_service->DismissAppList(); | 459 app_list_service->DismissAppList(); |
460 } | 460 } |
461 | 461 |
462 // Test AppListControllerDelegate::IsAppOpen for Arc apps. | 462 // Test AppListControllerDelegate::IsAppOpen for ARC apps. |
463 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, IsAppOpen) { | 463 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, IsAppOpen) { |
464 StartInstance(); | 464 StartInstance(); |
465 InstallTestApps(kTestAppPackage, false); | 465 InstallTestApps(kTestAppPackage, false); |
466 SendPackageAdded(kTestAppPackage, true); | 466 SendPackageAdded(kTestAppPackage, true); |
467 const std::string app_id = GetTestApp1Id(kTestAppPackage); | 467 const std::string app_id = GetTestApp1Id(kTestAppPackage); |
468 | 468 |
469 AppListService* service = AppListService::Get(); | 469 AppListService* service = AppListService::Get(); |
470 AppListControllerDelegate* delegate = service->GetControllerDelegate(); | 470 AppListControllerDelegate* delegate = service->GetControllerDelegate(); |
471 EXPECT_FALSE(delegate->IsAppOpen(app_id)); | 471 EXPECT_FALSE(delegate->IsAppOpen(app_id)); |
472 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); | 472 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 app_host()->OnTaskDestroyed(2); | 541 app_host()->OnTaskDestroyed(2); |
542 EXPECT_EQ(controller2, GetAppItemController(shelf_id2)); | 542 EXPECT_EQ(controller2, GetAppItemController(shelf_id2)); |
543 // Destroy task #2, this kills shelf group 2 | 543 // Destroy task #2, this kills shelf group 2 |
544 app_host()->OnTaskDestroyed(3); | 544 app_host()->OnTaskDestroyed(3); |
545 EXPECT_FALSE(GetAppItemController(shelf_id2)); | 545 EXPECT_FALSE(GetAppItemController(shelf_id2)); |
546 | 546 |
547 // Disable ARC, this removes app and as result kills shelf group 3. | 547 // Disable ARC, this removes app and as result kills shelf group 3. |
548 arc::ArcSessionManager::Get()->SetArcPlayStoreEnabled(false); | 548 arc::ArcSessionManager::Get()->SetArcPlayStoreEnabled(false); |
549 EXPECT_FALSE(GetAppItemController(shelf_id3)); | 549 EXPECT_FALSE(GetAppItemController(shelf_id3)); |
550 } | 550 } |
OLD | NEW |