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

Side by Side Diff: chrome/browser/ui/ash/launcher/arc_app_launcher_browsertest.cc

Issue 2791803002: mash: Move LauncherItemController to ash, rename ShelfItemDelegate. (Closed)
Patch Set: Sync and rebase. Created 3 years, 8 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 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/public/cpp/shelf_item_delegate.h"
6 #include "ash/shell.h" 7 #include "ash/shell.h"
7 #include "ash/wm/window_util.h" 8 #include "ash/wm/window_util.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" 13 #include "chrome/browser/chromeos/arc/arc_auth_notification.h"
13 #include "chrome/browser/chromeos/arc/arc_service_launcher.h" 14 #include "chrome/browser/chromeos/arc/arc_service_launcher.h"
14 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 15 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
15 #include "chrome/browser/chromeos/arc/arc_util.h" 16 #include "chrome/browser/chromeos/arc/arc_util.h"
16 #include "chrome/browser/extensions/extension_browsertest.h" 17 #include "chrome/browser/extensions/extension_browsertest.h"
17 #include "chrome/browser/ui/app_list/app_list_service.h" 18 #include "chrome/browser/ui/app_list/app_list_service.h"
18 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 19 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
19 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 20 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 21 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
21 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 22 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
22 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 23 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
23 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" 24 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
24 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 25 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
25 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
26 #include "components/arc/arc_util.h" 26 #include "components/arc/arc_util.h"
27 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
28 #include "ui/events/event_constants.h" 28 #include "ui/events/event_constants.h"
29 29
30 namespace mojo { 30 namespace mojo {
31 31
32 template <> 32 template <>
33 struct TypeConverter<arc::mojom::AppInfoPtr, arc::mojom::AppInfo> { 33 struct TypeConverter<arc::mojom::AppInfoPtr, arc::mojom::AppInfo> {
34 static arc::mojom::AppInfoPtr Convert(const arc::mojom::AppInfo& app_info) { 34 static arc::mojom::AppInfoPtr Convert(const arc::mojom::AppInfo& app_info) {
35 return app_info.Clone(); 35 return app_info.Clone();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (arc_session_manager()->profile() != profile()) 250 if (arc_session_manager()->profile() != profile())
251 arc::ArcServiceLauncher::Get()->OnPrimaryUserProfilePrepared(profile()); 251 arc::ArcServiceLauncher::Get()->OnPrimaryUserProfilePrepared(profile());
252 app_instance_observer()->OnInstanceReady(); 252 app_instance_observer()->OnInstanceReady();
253 } 253 }
254 254
255 void StopInstance() { 255 void StopInstance() {
256 arc_session_manager()->Shutdown(); 256 arc_session_manager()->Shutdown();
257 app_instance_observer()->OnInstanceClosed(); 257 app_instance_observer()->OnInstanceClosed();
258 } 258 }
259 259
260 LauncherItemController* GetAppItemController(const std::string& id) { 260 ash::ShelfItemDelegate* GetAppItemController(const std::string& id) {
261 const ash::ShelfID shelf_id = shelf_delegate()->GetShelfIDForAppID(id); 261 const ash::ShelfID shelf_id = shelf_delegate()->GetShelfIDForAppID(id);
262 if (!shelf_id) 262 if (!shelf_id)
263 return nullptr; 263 return nullptr;
264 return chrome_controller()->GetLauncherItemController(shelf_id); 264 return chrome_controller()->GetShelfItemDelegate(shelf_id);
265 } 265 }
266 266
267 ArcAppListPrefs* app_prefs() { return ArcAppListPrefs::Get(profile()); } 267 ArcAppListPrefs* app_prefs() { return ArcAppListPrefs::Get(profile()); }
268 268
269 // Returns as AppHost interface in order to access to private implementation 269 // Returns as AppHost interface in order to access to private implementation
270 // of the interface. 270 // of the interface.
271 arc::mojom::AppHost* app_host() { return app_prefs(); } 271 arc::mojom::AppHost* app_host() { return app_prefs(); }
272 272
273 // Returns as AppInstance observer interface in order to access to private 273 // Returns as AppInstance observer interface in order to access to private
274 // implementation of the interface. 274 // implementation of the interface.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); 357 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id));
358 else 358 else
359 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); 359 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id));
360 break; 360 break;
361 case TEST_ACTION_EXIT: 361 case TEST_ACTION_EXIT:
362 // Just exist Chrome. 362 // Just exist Chrome.
363 break; 363 break;
364 case TEST_ACTION_CLOSE: 364 case TEST_ACTION_CLOSE:
365 // Close item during animation. 365 // Close item during animation.
366 { 366 {
367 LauncherItemController* controller = GetAppItemController(app_id); 367 ash::ShelfItemDelegate* controller = GetAppItemController(app_id);
368 ASSERT_TRUE(controller); 368 ASSERT_TRUE(controller);
369 controller->Close(); 369 controller->Close();
370 EXPECT_TRUE(chrome_controller() 370 EXPECT_TRUE(chrome_controller()
371 ->GetArcDeferredLauncher() 371 ->GetArcDeferredLauncher()
372 ->GetActiveTime(app_id) 372 ->GetActiveTime(app_id)
373 .is_zero()); 373 .is_zero());
374 if (is_pinned()) 374 if (is_pinned())
375 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); 375 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id));
376 else 376 else
377 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); 377 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id));
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 arc::ArcAppShelfId(kTestShelfGroup, app_id).ToString(); 501 arc::ArcAppShelfId(kTestShelfGroup, app_id).ToString();
502 const std::string shelf_id2 = 502 const std::string shelf_id2 =
503 arc::ArcAppShelfId(kTestShelfGroup2, app_id).ToString(); 503 arc::ArcAppShelfId(kTestShelfGroup2, app_id).ToString();
504 const std::string shelf_id3 = 504 const std::string shelf_id3 =
505 arc::ArcAppShelfId(kTestShelfGroup3, app_id).ToString(); 505 arc::ArcAppShelfId(kTestShelfGroup3, app_id).ToString();
506 506
507 // 1 task for group 1 507 // 1 task for group 1
508 app_host()->OnTaskCreated(1, info->package_name, info->activity, info->name, 508 app_host()->OnTaskCreated(1, info->package_name, info->activity, info->name,
509 CreateIntentUriWithShelfGroup(kTestShelfGroup)); 509 CreateIntentUriWithShelfGroup(kTestShelfGroup));
510 510
511 LauncherItemController* controller1 = GetAppItemController(shelf_id1); 511 ash::ShelfItemDelegate* controller1 = GetAppItemController(shelf_id1);
512 ASSERT_TRUE(controller1); 512 ASSERT_TRUE(controller1);
513 513
514 // 2 tasks for group 2 514 // 2 tasks for group 2
515 app_host()->OnTaskCreated(2, info->package_name, info->activity, info->name, 515 app_host()->OnTaskCreated(2, info->package_name, info->activity, info->name,
516 CreateIntentUriWithShelfGroup(kTestShelfGroup2)); 516 CreateIntentUriWithShelfGroup(kTestShelfGroup2));
517 517
518 LauncherItemController* controller2 = GetAppItemController(shelf_id2); 518 ash::ShelfItemDelegate* controller2 = GetAppItemController(shelf_id2);
519 ASSERT_TRUE(controller2); 519 ASSERT_TRUE(controller2);
520 ASSERT_NE(controller1, controller2); 520 ASSERT_NE(controller1, controller2);
521 521
522 app_host()->OnTaskCreated(3, info->package_name, info->activity, info->name, 522 app_host()->OnTaskCreated(3, info->package_name, info->activity, info->name,
523 CreateIntentUriWithShelfGroup(kTestShelfGroup2)); 523 CreateIntentUriWithShelfGroup(kTestShelfGroup2));
524 524
525 ASSERT_EQ(controller2, GetAppItemController(shelf_id2)); 525 ASSERT_EQ(controller2, GetAppItemController(shelf_id2));
526 526
527 // 2 tasks for group 3 which does not have shortcut. 527 // 2 tasks for group 3 which does not have shortcut.
528 app_host()->OnTaskCreated(4, info->package_name, info->activity, info->name, 528 app_host()->OnTaskCreated(4, info->package_name, info->activity, info->name,
529 CreateIntentUriWithShelfGroup(kTestShelfGroup3)); 529 CreateIntentUriWithShelfGroup(kTestShelfGroup3));
530 530
531 LauncherItemController* controller3 = GetAppItemController(shelf_id3); 531 ash::ShelfItemDelegate* controller3 = GetAppItemController(shelf_id3);
532 ASSERT_TRUE(controller3); 532 ASSERT_TRUE(controller3);
533 ASSERT_NE(controller1, controller3); 533 ASSERT_NE(controller1, controller3);
534 ASSERT_NE(controller2, controller3); 534 ASSERT_NE(controller2, controller3);
535 535
536 app_host()->OnTaskCreated(5, info->package_name, info->activity, info->name, 536 app_host()->OnTaskCreated(5, info->package_name, info->activity, info->name,
537 CreateIntentUriWithShelfGroup(kTestShelfGroup3)); 537 CreateIntentUriWithShelfGroup(kTestShelfGroup3));
538 538
539 ASSERT_EQ(controller3, GetAppItemController(shelf_id3)); 539 ASSERT_EQ(controller3, GetAppItemController(shelf_id3));
540 540
541 // Destroy task #0, this kills shelf group 1 541 // Destroy task #0, this kills shelf group 1
542 app_host()->OnTaskDestroyed(1); 542 app_host()->OnTaskDestroyed(1);
543 EXPECT_FALSE(GetAppItemController(shelf_id1)); 543 EXPECT_FALSE(GetAppItemController(shelf_id1));
544 544
545 // Destroy task #1, shelf group 2 is still alive 545 // Destroy task #1, shelf group 2 is still alive
546 app_host()->OnTaskDestroyed(2); 546 app_host()->OnTaskDestroyed(2);
547 EXPECT_EQ(controller2, GetAppItemController(shelf_id2)); 547 EXPECT_EQ(controller2, GetAppItemController(shelf_id2));
548 // Destroy task #2, this kills shelf group 2 548 // Destroy task #2, this kills shelf group 2
549 app_host()->OnTaskDestroyed(3); 549 app_host()->OnTaskDestroyed(3);
550 EXPECT_FALSE(GetAppItemController(shelf_id2)); 550 EXPECT_FALSE(GetAppItemController(shelf_id2));
551 551
552 // Disable ARC, this removes app and as result kills shelf group 3. 552 // Disable ARC, this removes app and as result kills shelf group 3.
553 arc::SetArcPlayStoreEnabledForProfile(profile(), false); 553 arc::SetArcPlayStoreEnabledForProfile(profile(), false);
554 EXPECT_FALSE(GetAppItemController(shelf_id3)); 554 EXPECT_FALSE(GetAppItemController(shelf_id3));
555 } 555 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698