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

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

Issue 2839933005: mash: Merge ChromeLauncherController and *Impl subclass. (Closed)
Patch Set: Address comments. 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 tab_id_map_[tab] = id; 221 tab_id_map_[tab] = id;
222 } 222 }
223 223
224 // Returns true if there is an id registered for |tab|. 224 // Returns true if there is an id registered for |tab|.
225 bool HasAppID(content::WebContents* tab) const { 225 bool HasAppID(content::WebContents* tab) const {
226 return tab_id_map_.find(tab) != tab_id_map_.end(); 226 return tab_id_map_.find(tab) != tab_id_map_.end();
227 } 227 }
228 228
229 // LauncherControllerHelper: 229 // LauncherControllerHelper:
230 std::string GetAppID(content::WebContents* tab) override { 230 std::string GetAppID(content::WebContents* tab) override {
231 return tab_id_map_.find(tab) != tab_id_map_.end() ? tab_id_map_[tab] : 231 return tab_id_map_.find(tab) != tab_id_map_.end() ? tab_id_map_[tab]
232 std::string(); 232 : std::string();
233 } 233 }
234 234
235 bool IsValidIDForCurrentUser(const std::string& id) const override { 235 bool IsValidIDForCurrentUser(const std::string& id) const override {
236 for (TabToStringMap::const_iterator i = tab_id_map_.begin(); 236 for (TabToStringMap::const_iterator i = tab_id_map_.begin();
237 i != tab_id_map_.end(); ++i) { 237 i != tab_id_map_.end(); ++i) {
238 if (i->second == id) 238 if (i->second == id)
239 return true; 239 return true;
240 } 240 }
241 return false; 241 return false;
242 } 242 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 void SelectItem(ash::ShelfItemDelegate* delegate) { 333 void SelectItem(ash::ShelfItemDelegate* delegate) {
334 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::MouseEvent>( 334 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::MouseEvent>(
335 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), 335 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
336 ui::EF_NONE, 0); 336 ui::EF_NONE, 0);
337 delegate->ItemSelected(std::move(event), display::kInvalidDisplayId, 337 delegate->ItemSelected(std::move(event), display::kInvalidDisplayId,
338 ash::LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback)); 338 ash::LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback));
339 } 339 }
340 340
341 } // namespace 341 } // namespace
342 342
343 // A test ChromeLauncherControllerImpl subclass that uses TestShelfController. 343 // A test ChromeLauncherController subclass that uses TestShelfController.
344 class TestChromeLauncherControllerImpl : public ChromeLauncherControllerImpl { 344 class TestChromeLauncherController : public ChromeLauncherController {
345 public: 345 public:
346 TestChromeLauncherControllerImpl(Profile* profile, ash::ShelfModel* model) 346 TestChromeLauncherController(Profile* profile, ash::ShelfModel* model)
347 : ChromeLauncherControllerImpl(profile, model) {} 347 : ChromeLauncherController(profile, model) {}
348 348
349 // ChromeLauncherControllerImpl: 349 // ChromeLauncherController:
350 using ChromeLauncherControllerImpl::ReleaseProfile; 350 using ChromeLauncherController::AttachProfile;
351 using ChromeLauncherController::ReleaseProfile;
351 bool ConnectToShelfController() override { 352 bool ConnectToShelfController() override {
352 // Set the shelf controller pointer to a test instance; this is run in init. 353 // Set the shelf controller pointer to a test instance; this is run in init.
353 if (!shelf_controller_.is_bound()) 354 if (!shelf_controller_.is_bound())
354 shelf_controller_ = test_shelf_controller_.CreateInterfacePtrAndBind(); 355 shelf_controller_ = test_shelf_controller_.CreateInterfacePtrAndBind();
355 return true; 356 return true;
356 } 357 }
357 358
358 TestShelfController* test_shelf_controller() { 359 TestShelfController* test_shelf_controller() {
359 return &test_shelf_controller_; 360 return &test_shelf_controller_;
360 } 361 }
361 362
362 private: 363 private:
363 TestShelfController test_shelf_controller_; 364 TestShelfController test_shelf_controller_;
364 365
365 DISALLOW_COPY_AND_ASSIGN(TestChromeLauncherControllerImpl); 366 DISALLOW_COPY_AND_ASSIGN(TestChromeLauncherController);
366 }; 367 };
367 368
368 // A shell delegate that owns a ChromeLauncherController, like production. 369 // A shell delegate that owns a ChromeLauncherController, like production.
369 // TODO(msw): Refine ChromeLauncherControllerImpl lifetime management. 370 // TODO(msw): Refine ChromeLauncherController lifetime management.
370 // TODO(msw): Avoid relying on TestShellDelegate's ShelfInitializer. 371 // TODO(msw): Avoid relying on TestShellDelegate's ShelfInitializer.
371 class ChromeLauncherTestShellDelegate : public ash::test::TestShellDelegate { 372 class ChromeLauncherTestShellDelegate : public ash::test::TestShellDelegate {
372 public: 373 public:
373 ChromeLauncherTestShellDelegate() {} 374 ChromeLauncherTestShellDelegate() {}
374 375
375 // Create a ChromeLauncherControllerImpl instance. 376 // Create a ChromeLauncherController instance.
376 ChromeLauncherControllerImpl* CreateLauncherController(Profile* profile) { 377 ChromeLauncherController* CreateLauncherController(Profile* profile) {
377 launcher_controller_ = base::MakeUnique<ChromeLauncherControllerImpl>( 378 launcher_controller_ = base::MakeUnique<ChromeLauncherController>(
378 profile, ash::Shell::Get()->shelf_model()); 379 profile, ash::Shell::Get()->shelf_model());
379 return launcher_controller_.get(); 380 return launcher_controller_.get();
380 } 381 }
381 382
382 // Create a TestChromeLauncherControllerImpl instance. 383 // Create a TestChromeLauncherController instance.
383 TestChromeLauncherControllerImpl* CreateTestLauncherController( 384 TestChromeLauncherController* CreateTestLauncherController(Profile* profile) {
384 Profile* profile) { 385 auto controller = base::MakeUnique<TestChromeLauncherController>(
385 auto controller = base::MakeUnique<TestChromeLauncherControllerImpl>(
386 profile, ash::Shell::Get()->shelf_model()); 386 profile, ash::Shell::Get()->shelf_model());
387 TestChromeLauncherControllerImpl* controller_weak = controller.get(); 387 TestChromeLauncherController* controller_weak = controller.get();
388 launcher_controller_ = std::move(controller); 388 launcher_controller_ = std::move(controller);
389 launcher_controller_->Init(); 389 launcher_controller_->Init();
390 return controller_weak; 390 return controller_weak;
391 } 391 }
392 392
393 // ash::test::TestShellDelegate: 393 // ash::test::TestShellDelegate:
394 void ShelfShutdown() override { launcher_controller_.reset(); } 394 void ShelfShutdown() override { launcher_controller_.reset(); }
395 395
396 private: 396 private:
397 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; 397 std::unique_ptr<ChromeLauncherController> launcher_controller_;
398 398
399 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherTestShellDelegate); 399 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherTestShellDelegate);
400 }; 400 };
401 401
402 class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest { 402 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest {
403 protected: 403 protected:
404 ChromeLauncherControllerImplTest() 404 ChromeLauncherControllerTest()
405 : BrowserWithTestWindowTest(Browser::TYPE_TABBED, false) {} 405 : BrowserWithTestWindowTest(Browser::TYPE_TABBED, false) {}
406 406
407 ~ChromeLauncherControllerImplTest() override {} 407 ~ChromeLauncherControllerTest() override {}
408 408
409 void SetUp() override { 409 void SetUp() override {
410 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 410 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
411 command_line->AppendSwitch(switches::kUseFirstDisplayAsInternal); 411 command_line->AppendSwitch(switches::kUseFirstDisplayAsInternal);
412 412
413 app_list::AppListSyncableServiceFactory::SetUseInTesting(); 413 app_list::AppListSyncableServiceFactory::SetUseInTesting();
414 414
415 shell_delegate_ = new ChromeLauncherTestShellDelegate(); 415 shell_delegate_ = new ChromeLauncherTestShellDelegate();
416 ash_test_helper()->set_test_shell_delegate(shell_delegate_); 416 ash_test_helper()->set_test_shell_delegate(shell_delegate_);
417 417
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 595 }
596 596
597 void AddAppListLauncherItem() { 597 void AddAppListLauncherItem() {
598 ash::ShelfItem app_list; 598 ash::ShelfItem app_list;
599 app_list.type = ash::TYPE_APP_LIST; 599 app_list.type = ash::TYPE_APP_LIST;
600 model_->Add(app_list); 600 model_->Add(app_list);
601 } 601 }
602 602
603 // Create a launcher controller instance, owned by the test shell delegate. 603 // Create a launcher controller instance, owned by the test shell delegate.
604 // Returns a pointer to the uninitialized controller. 604 // Returns a pointer to the uninitialized controller.
605 ChromeLauncherControllerImpl* CreateLauncherController() { 605 ChromeLauncherController* CreateLauncherController() {
606 launcher_controller_ = shell_delegate_->CreateLauncherController(profile()); 606 launcher_controller_ = shell_delegate_->CreateLauncherController(profile());
607 return launcher_controller_; 607 return launcher_controller_;
608 } 608 }
609 609
610 // Create and initialize the controller, owned by the test shell delegate. 610 // Create and initialize the controller, owned by the test shell delegate.
611 void InitLauncherController() { CreateLauncherController()->Init(); } 611 void InitLauncherController() { CreateLauncherController()->Init(); }
612 612
613 // Create and initialize the controller; create a tab and show the browser. 613 // Create and initialize the controller; create a tab and show the browser.
614 void InitLauncherControllerWithBrowser() { 614 void InitLauncherControllerWithBrowser() {
615 InitLauncherController(); 615 InitLauncherController();
616 chrome::NewTab(browser()); 616 chrome::NewTab(browser());
617 browser()->window()->Show(); 617 browser()->window()->Show();
618 } 618 }
619 619
620 // Destroy the launcher controller instance and clear the local pointer. 620 // Destroy the launcher controller instance and clear the local pointer.
621 void ResetLauncherController() { 621 void ResetLauncherController() {
622 launcher_controller_ = nullptr; 622 launcher_controller_ = nullptr;
623 shell_delegate_->ShelfShutdown(); 623 shell_delegate_->ShelfShutdown();
624 } 624 }
625 625
626 // Destroy and recreate the controller; clear and reinitialize the ShelfModel. 626 // Destroy and recreate the controller; clear and reinitialize the ShelfModel.
627 // Returns a pointer to the uninitialized controller, owned by shell delegate. 627 // Returns a pointer to the uninitialized controller, owned by shell delegate.
628 // TODO(msw): This does not accurately represent ChromeLauncherControllerImpl 628 // TODO(msw): This does not accurately represent ChromeLauncherController
629 // lifetime or usage in production, and does not accurately simulate restarts. 629 // lifetime or usage in production, and does not accurately simulate restarts.
630 ChromeLauncherControllerImpl* RecreateLauncherController() { 630 ChromeLauncherController* RecreateLauncherController() {
631 // Destroy any existing controller first; only one may exist at a time. 631 // Destroy any existing controller first; only one may exist at a time.
632 ResetLauncherController(); 632 ResetLauncherController();
633 while (model_->item_count() > 0) 633 while (model_->item_count() > 0)
634 model_->RemoveItemAt(0); 634 model_->RemoveItemAt(0);
635 AddAppListLauncherItem(); 635 AddAppListLauncherItem();
636 return CreateLauncherController(); 636 return CreateLauncherController();
637 } 637 }
638 638
639 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { 639 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) {
640 app_service_->MergeDataAndStartSyncing( 640 app_service_->MergeDataAndStartSyncing(
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 app_list_specifics->set_item_type(sync_pb::AppListSpecifics::TYPE_APP); 815 app_list_specifics->set_item_type(sync_pb::AppListSpecifics::TYPE_APP);
816 app_list_specifics->set_item_pin_ordinal(chrome_position.ToInternalValue()); 816 app_list_specifics->set_item_pin_ordinal(chrome_position.ToInternalValue());
817 syncer::SyncData sync_data = syncer::SyncData::CreateLocalData( 817 syncer::SyncData sync_data = syncer::SyncData::CreateLocalData(
818 extension_misc::kChromeAppId, "Test", specifics); 818 extension_misc::kChromeAppId, "Test", specifics);
819 sync_list.push_back(syncer::SyncChange( 819 sync_list.push_back(syncer::SyncChange(
820 FROM_HERE, syncer::SyncChange::ACTION_UPDATE, sync_data)); 820 FROM_HERE, syncer::SyncChange::ACTION_UPDATE, sync_data));
821 app_service_->ProcessSyncChanges(FROM_HERE, sync_list); 821 app_service_->ProcessSyncChanges(FROM_HERE, sync_list);
822 } 822 }
823 823
824 // Gets the IDs of the currently pinned app items. 824 // Gets the IDs of the currently pinned app items.
825 void GetPinnedAppIds(ChromeLauncherControllerImpl* controller, 825 void GetPinnedAppIds(ChromeLauncherController* controller,
826 std::vector<std::string>* app_ids) { 826 std::vector<std::string>* app_ids) {
827 app_ids->clear(); 827 app_ids->clear();
828 for (const auto& item : model_->items()) { 828 for (const auto& item : model_->items()) {
829 if (item.type == ash::TYPE_PINNED_APP) 829 if (item.type == ash::TYPE_PINNED_APP)
830 app_ids->push_back(item.app_launch_id.app_id()); 830 app_ids->push_back(item.app_launch_id.app_id());
831 } 831 }
832 } 832 }
833 833
834 // Get the setup of the currently shown launcher items in one string. 834 // Get the setup of the currently shown launcher items in one string.
835 // Each pinned element will start with a big letter, each running but not 835 // Each pinned element will start with a big letter, each running but not
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 scoped_refptr<Extension> extension4_; 1039 scoped_refptr<Extension> extension4_;
1040 scoped_refptr<Extension> extension5_; 1040 scoped_refptr<Extension> extension5_;
1041 scoped_refptr<Extension> extension6_; 1041 scoped_refptr<Extension> extension6_;
1042 scoped_refptr<Extension> extension7_; 1042 scoped_refptr<Extension> extension7_;
1043 scoped_refptr<Extension> extension8_; 1043 scoped_refptr<Extension> extension8_;
1044 scoped_refptr<Extension> extension_platform_app_; 1044 scoped_refptr<Extension> extension_platform_app_;
1045 scoped_refptr<Extension> arc_support_host_; 1045 scoped_refptr<Extension> arc_support_host_;
1046 1046
1047 ArcAppTest arc_test_; 1047 ArcAppTest arc_test_;
1048 bool auto_start_arc_test_ = false; 1048 bool auto_start_arc_test_ = false;
1049 ChromeLauncherControllerImpl* launcher_controller_ = nullptr; 1049 ChromeLauncherController* launcher_controller_ = nullptr;
1050 ChromeLauncherTestShellDelegate* shell_delegate_ = nullptr; 1050 ChromeLauncherTestShellDelegate* shell_delegate_ = nullptr;
1051 std::unique_ptr<TestShelfModelObserver> model_observer_; 1051 std::unique_ptr<TestShelfModelObserver> model_observer_;
1052 ash::ShelfModel* model_ = nullptr; 1052 ash::ShelfModel* model_ = nullptr;
1053 std::unique_ptr<TestingProfileManager> profile_manager_; 1053 std::unique_ptr<TestingProfileManager> profile_manager_;
1054 1054
1055 // |item_delegate_manager_| owns |test_controller_|. 1055 // |item_delegate_manager_| owns |test_controller_|.
1056 ash::ShelfItemDelegate* test_controller_ = nullptr; 1056 ash::ShelfItemDelegate* test_controller_ = nullptr;
1057 1057
1058 ExtensionService* extension_service_ = nullptr; 1058 ExtensionService* extension_service_ = nullptr;
1059 1059
1060 app_list::AppListSyncableService* app_service_ = nullptr; 1060 app_list::AppListSyncableService* app_service_ = nullptr;
1061 1061
1062 private: 1062 private:
1063 TestBrowserWindow* CreateTestBrowserWindowAura() { 1063 TestBrowserWindow* CreateTestBrowserWindowAura() {
1064 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); 1064 std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
1065 window->set_id(0); 1065 window->set_id(0);
1066 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 1066 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
1067 window->Init(ui::LAYER_TEXTURED); 1067 window->Init(ui::LAYER_TEXTURED);
1068 aura::client::ParentWindowWithContext(window.get(), GetContext(), 1068 aura::client::ParentWindowWithContext(window.get(), GetContext(),
1069 gfx::Rect(200, 200)); 1069 gfx::Rect(200, 200));
1070 1070
1071 return new TestBrowserWindowAura(std::move(window)); 1071 return new TestBrowserWindowAura(std::move(window));
1072 } 1072 }
1073 1073
1074 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest); 1074 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest);
1075 }; 1075 };
1076 1076
1077 class ChromeLauncherControllerImplWithArcTest 1077 class ChromeLauncherControllerWithArcTest
1078 : public ChromeLauncherControllerImplTest, 1078 : public ChromeLauncherControllerTest,
1079 public ::testing::WithParamInterface<bool> { 1079 public ::testing::WithParamInterface<bool> {
1080 protected: 1080 protected:
1081 ChromeLauncherControllerImplWithArcTest() { auto_start_arc_test_ = true; } 1081 ChromeLauncherControllerWithArcTest() { auto_start_arc_test_ = true; }
1082 ~ChromeLauncherControllerImplWithArcTest() override {} 1082 ~ChromeLauncherControllerWithArcTest() override {}
1083 1083
1084 void SetUp() override { 1084 void SetUp() override {
1085 if (GetParam()) 1085 if (GetParam())
1086 arc::SetArcAlwaysStartForTesting(); 1086 arc::SetArcAlwaysStartForTesting();
1087 ChromeLauncherControllerImplTest::SetUp(); 1087 ChromeLauncherControllerTest::SetUp();
1088 } 1088 }
1089 1089
1090 private: 1090 private:
1091 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplWithArcTest); 1091 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerWithArcTest);
1092 }; 1092 };
1093 1093
1094 INSTANTIATE_TEST_CASE_P(, 1094 INSTANTIATE_TEST_CASE_P(,
1095 ChromeLauncherControllerImplWithArcTest, 1095 ChromeLauncherControllerWithArcTest,
1096 ::testing::Bool()); 1096 ::testing::Bool());
1097 1097
1098 // Watches WebContents and blocks until it is destroyed. This is needed for 1098 // Watches WebContents and blocks until it is destroyed. This is needed for
1099 // the destruction of a V2 application. 1099 // the destruction of a V2 application.
1100 class WebContentsDestroyedWatcher : public content::WebContentsObserver { 1100 class WebContentsDestroyedWatcher : public content::WebContentsObserver {
1101 public: 1101 public:
1102 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) 1102 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents)
1103 : content::WebContentsObserver(web_contents), 1103 : content::WebContentsObserver(web_contents),
1104 message_loop_runner_(new content::MessageLoopRunner) { 1104 message_loop_runner_(new content::MessageLoopRunner) {
1105 EXPECT_TRUE(web_contents != NULL); 1105 EXPECT_TRUE(web_contents != NULL);
1106 } 1106 }
1107 ~WebContentsDestroyedWatcher() override {} 1107 ~WebContentsDestroyedWatcher() override {}
1108 1108
1109 // Waits until the WebContents is destroyed. 1109 // Waits until the WebContents is destroyed.
1110 void Wait() { 1110 void Wait() { message_loop_runner_->Run(); }
1111 message_loop_runner_->Run();
1112 }
1113 1111
1114 private: 1112 private:
1115 // Overridden WebContentsObserver methods. 1113 // Overridden WebContentsObserver methods.
1116 void WebContentsDestroyed() override { message_loop_runner_->Quit(); } 1114 void WebContentsDestroyed() override { message_loop_runner_->Quit(); }
1117 1115
1118 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 1116 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
1119 1117
1120 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); 1118 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher);
1121 }; 1119 };
1122 1120
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1181
1184 // The app window which represents the application. Note that the window 1182 // The app window which represents the application. Note that the window
1185 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets 1183 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets
1186 // called. 1184 // called.
1187 extensions::AppWindow* window_; 1185 extensions::AppWindow* window_;
1188 1186
1189 DISALLOW_COPY_AND_ASSIGN(V2App); 1187 DISALLOW_COPY_AND_ASSIGN(V2App);
1190 }; 1188 };
1191 1189
1192 // The testing framework to test multi profile scenarios. 1190 // The testing framework to test multi profile scenarios.
1193 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest 1191 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest
1194 : public ChromeLauncherControllerImplTest { 1192 : public ChromeLauncherControllerTest {
1195 protected: 1193 protected:
1196 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest() {} 1194 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() {}
1197 1195
1198 ~MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest() 1196 ~MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() override {}
1199 override {}
1200 1197
1201 // Overwrite the Setup function to enable multi profile and needed objects. 1198 // Overwrite the Setup function to enable multi profile and needed objects.
1202 void SetUp() override { 1199 void SetUp() override {
1203 profile_manager_.reset( 1200 profile_manager_.reset(
1204 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 1201 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
1205 1202
1206 ASSERT_TRUE(profile_manager_->SetUp()); 1203 ASSERT_TRUE(profile_manager_->SetUp());
1207 1204
1208 // AvatarMenu and multiple profiles works after user logged in. 1205 // AvatarMenu and multiple profiles works after user logged in.
1209 profile_manager_->SetLoggedIn(true); 1206 profile_manager_->SetLoggedIn(true);
1210 1207
1211 // Initialize the UserManager singleton to a fresh FakeUserManager instance. 1208 // Initialize the UserManager singleton to a fresh FakeUserManager instance.
1212 user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler( 1209 user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler(
1213 new chromeos::FakeChromeUserManager)); 1210 new chromeos::FakeChromeUserManager));
1214 1211
1215 // Initialize the WallpaperManager singleton. 1212 // Initialize the WallpaperManager singleton.
1216 chromeos::WallpaperManager::Initialize(); 1213 chromeos::WallpaperManager::Initialize();
1217 1214
1218 // Initialize the rest. 1215 // Initialize the rest.
1219 ChromeLauncherControllerImplTest::SetUp(); 1216 ChromeLauncherControllerTest::SetUp();
1220 shell_delegate_->set_multi_profiles_enabled(true); 1217 shell_delegate_->set_multi_profiles_enabled(true);
1221 } 1218 }
1222 1219
1223 void TearDown() override { 1220 void TearDown() override {
1224 ChromeLauncherControllerImplTest::TearDown(); 1221 ChromeLauncherControllerTest::TearDown();
1225 user_manager_enabler_.reset(); 1222 user_manager_enabler_.reset();
1226 for (ProfileToNameMap::iterator it = created_profiles_.begin(); 1223 for (ProfileToNameMap::iterator it = created_profiles_.begin();
1227 it != created_profiles_.end(); ++it) 1224 it != created_profiles_.end(); ++it)
1228 profile_manager_->DeleteTestingProfile(it->second); 1225 profile_manager_->DeleteTestingProfile(it->second);
1229 chromeos::WallpaperManager::Shutdown(); 1226 chromeos::WallpaperManager::Shutdown();
1230 1227
1231 // A Task is leaked if we don't destroy everything, then run the message 1228 // A Task is leaked if we don't destroy everything, then run the message
1232 // loop. 1229 // loop.
1233 base::RunLoop().RunUntilIdle(); 1230 base::RunLoop().RunUntilIdle();
1234 } 1231 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 chromeos::FakeChromeUserManager* GetFakeUserManager() { 1317 chromeos::FakeChromeUserManager* GetFakeUserManager() {
1321 return static_cast<chromeos::FakeChromeUserManager*>( 1318 return static_cast<chromeos::FakeChromeUserManager*>(
1322 user_manager::UserManager::Get()); 1319 user_manager::UserManager::Get());
1323 } 1320 }
1324 1321
1325 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; 1322 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_;
1326 1323
1327 ProfileToNameMap created_profiles_; 1324 ProfileToNameMap created_profiles_;
1328 1325
1329 DISALLOW_COPY_AND_ASSIGN( 1326 DISALLOW_COPY_AND_ASSIGN(
1330 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); 1327 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest);
1331 }; 1328 };
1332 1329
1333 class ChromeLauncherControllerImplMultiProfileWithArcTest 1330 class ChromeLauncherControllerMultiProfileWithArcTest
1334 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest , // NOLINT(whitespace/line_length) 1331 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
1335 public ::testing::WithParamInterface<bool> { 1332 public ::testing::WithParamInterface<bool> {
1336 protected: 1333 protected:
1337 ChromeLauncherControllerImplMultiProfileWithArcTest() { 1334 ChromeLauncherControllerMultiProfileWithArcTest() {
1338 auto_start_arc_test_ = true; 1335 auto_start_arc_test_ = true;
1339 } 1336 }
1340 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} 1337 ~ChromeLauncherControllerMultiProfileWithArcTest() override {}
1341 1338
1342 void SetUp() override { 1339 void SetUp() override {
1343 if (GetParam()) 1340 if (GetParam())
1344 arc::SetArcAlwaysStartForTesting(); 1341 arc::SetArcAlwaysStartForTesting();
1345 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest:: 1342 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest::SetUp();
1346 SetUp();
1347 } 1343 }
1348 1344
1349 private: 1345 private:
1350 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); 1346 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerMultiProfileWithArcTest);
1351 }; 1347 };
1352 1348
1353 INSTANTIATE_TEST_CASE_P(, 1349 INSTANTIATE_TEST_CASE_P(,
1354 ChromeLauncherControllerImplMultiProfileWithArcTest, 1350 ChromeLauncherControllerMultiProfileWithArcTest,
1355 ::testing::Bool()); 1351 ::testing::Bool());
1356 1352
1357 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) { 1353 TEST_F(ChromeLauncherControllerTest, DefaultApps) {
1358 InitLauncherController(); 1354 InitLauncherController();
1359 // The model should only contain the browser shortcut and app list items. 1355 // The model should only contain the browser shortcut and app list items.
1360 EXPECT_EQ(2, model_->item_count()); 1356 EXPECT_EQ(2, model_->item_count());
1361 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1357 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1362 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1358 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1363 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1359 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1364 1360
1365 // Installing |extension3_| should add it to the launcher - behind the 1361 // Installing |extension3_| should add it to the launcher - behind the
1366 // chrome icon. 1362 // chrome icon.
1367 extension_service_->AddExtension(extension3_.get()); 1363 extension_service_->AddExtension(extension3_.get());
1368 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1364 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1369 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1365 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1370 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1366 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1371 } 1367 }
1372 1368
1373 TEST_P(ChromeLauncherControllerImplWithArcTest, 1369 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPinCrossPlatformWorkflow) {
1374 ArcAppPinCrossPlatformWorkflow) {
1375 // Work on ARC disabled platform first. 1370 // Work on ARC disabled platform first.
1376 const std::string arc_app_id1 = 1371 const std::string arc_app_id1 =
1377 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1372 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1378 const std::string arc_app_id2 = 1373 const std::string arc_app_id2 =
1379 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1374 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1380 const std::string arc_app_id3 = 1375 const std::string arc_app_id3 =
1381 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); 1376 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]);
1382 1377
1383 InitLauncherController(); 1378 InitLauncherController();
1384 1379
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1469 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1475 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); 1470 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
1476 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1471 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1477 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); 1472 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2));
1478 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 1473 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
1479 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); 1474 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3));
1480 EXPECT_EQ("AppList, Fake App 1, App3, Chrome, App1, Fake App 0", 1475 EXPECT_EQ("AppList, Fake App 1, App3, Chrome, App1, Fake App 0",
1481 GetPinnedAppStatus()); 1476 GetPinnedAppStatus());
1482 } 1477 }
1483 1478
1484 /* 1479 // Ensure correct merging of policy pinned apps and user pinned apps.
1485 * Test ChromeLauncherControllerImpl correctly merges policy pinned apps 1480 TEST_F(ChromeLauncherControllerTest, MergePolicyAndUserPrefPinnedApps) {
1486 * and user pinned apps
1487 */
1488 TEST_F(ChromeLauncherControllerImplTest, MergePolicyAndUserPrefPinnedApps) {
1489 InitLauncherController(); 1481 InitLauncherController();
1490 1482
1491 extension_service_->AddExtension(extension1_.get()); 1483 extension_service_->AddExtension(extension1_.get());
1492 extension_service_->AddExtension(extension3_.get()); 1484 extension_service_->AddExtension(extension3_.get());
1493 extension_service_->AddExtension(extension4_.get()); 1485 extension_service_->AddExtension(extension4_.get());
1494 extension_service_->AddExtension(extension5_.get()); 1486 extension_service_->AddExtension(extension5_.get());
1495 // extension 1, 3 are pinned by user 1487 // extension 1, 3 are pinned by user
1496 syncer::SyncChangeList sync_list; 1488 syncer::SyncChangeList sync_list;
1497 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1489 InsertAddPinChange(&sync_list, 0, extension1_->id());
1498 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId); 1490 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId);
(...skipping 26 matching lines...) Expand all
1525 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 1517 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
1526 GetPinnableForAppID(extension4_->id(), profile())); 1518 GetPinnableForAppID(extension4_->id(), profile()));
1527 1519
1528 // Check the order of shelf pinned apps 1520 // Check the order of shelf pinned apps
1529 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus()); 1521 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus());
1530 } 1522 }
1531 1523
1532 // Check that the restauration of launcher items is happening in the same order 1524 // Check that the restauration of launcher items is happening in the same order
1533 // as the user has pinned them (on another system) when they are synced reverse 1525 // as the user has pinned them (on another system) when they are synced reverse
1534 // order. 1526 // order.
1535 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsReverseOrder) { 1527 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsReverseOrder) {
1536 InitLauncherController(); 1528 InitLauncherController();
1537 1529
1538 syncer::SyncChangeList sync_list; 1530 syncer::SyncChangeList sync_list;
1539 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1531 InsertAddPinChange(&sync_list, 0, extension1_->id());
1540 InsertAddPinChange(&sync_list, 1, extension2_->id()); 1532 InsertAddPinChange(&sync_list, 1, extension2_->id());
1541 InsertAddPinChange(&sync_list, 2, extension3_->id()); 1533 InsertAddPinChange(&sync_list, 2, extension3_->id());
1542 SendPinChanges(sync_list, true); 1534 SendPinChanges(sync_list, true);
1543 1535
1544 // The model should only contain the browser shortcut and app list items. 1536 // The model should only contain the browser shortcut and app list items.
1545 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1537 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
(...skipping 17 matching lines...) Expand all
1563 1555
1564 // Installing |extension1_| should add it to the launcher - behind the 1556 // Installing |extension1_| should add it to the launcher - behind the
1565 // chrome icon, but in first location. 1557 // chrome icon, but in first location.
1566 extension_service_->AddExtension(extension1_.get()); 1558 extension_service_->AddExtension(extension1_.get());
1567 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus()); 1559 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus());
1568 } 1560 }
1569 1561
1570 // Check that the restauration of launcher items is happening in the same order 1562 // Check that the restauration of launcher items is happening in the same order
1571 // as the user has pinned them (on another system) when they are synced random 1563 // as the user has pinned them (on another system) when they are synced random
1572 // order. 1564 // order.
1573 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsRandomOrder) { 1565 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrder) {
1574 InitLauncherController(); 1566 InitLauncherController();
1575 1567
1576 syncer::SyncChangeList sync_list; 1568 syncer::SyncChangeList sync_list;
1577 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1569 InsertAddPinChange(&sync_list, 0, extension1_->id());
1578 InsertAddPinChange(&sync_list, 1, extension2_->id()); 1570 InsertAddPinChange(&sync_list, 1, extension2_->id());
1579 InsertAddPinChange(&sync_list, 2, extension3_->id()); 1571 InsertAddPinChange(&sync_list, 2, extension3_->id());
1580 SendPinChanges(sync_list, true); 1572 SendPinChanges(sync_list, true);
1581 1573
1582 // The model should only contain the browser shortcut and app list items. 1574 // The model should only contain the browser shortcut and app list items.
1583 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1575 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
(...skipping 16 matching lines...) Expand all
1600 1592
1601 // Installing |extension3_| should add it to the launcher - behind the 1593 // Installing |extension3_| should add it to the launcher - behind the
1602 // chrome icon, but in first location. 1594 // chrome icon, but in first location.
1603 extension_service_->AddExtension(extension3_.get()); 1595 extension_service_->AddExtension(extension3_.get());
1604 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus()); 1596 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus());
1605 } 1597 }
1606 1598
1607 // Check that the restauration of launcher items is happening in the same order 1599 // Check that the restauration of launcher items is happening in the same order
1608 // as the user has pinned / moved them (on another system) when they are synced 1600 // as the user has pinned / moved them (on another system) when they are synced
1609 // random order - including the chrome icon. 1601 // random order - including the chrome icon.
1610 TEST_F(ChromeLauncherControllerImplTest, 1602 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrderChromeMoved) {
1611 RestoreDefaultAppsRandomOrderChromeMoved) {
1612 InitLauncherController(); 1603 InitLauncherController();
1613 1604
1614 syncer::SyncChangeList sync_list; 1605 syncer::SyncChangeList sync_list;
1615 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1606 InsertAddPinChange(&sync_list, 0, extension1_->id());
1616 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId); 1607 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId);
1617 InsertAddPinChange(&sync_list, 2, extension2_->id()); 1608 InsertAddPinChange(&sync_list, 2, extension2_->id());
1618 InsertAddPinChange(&sync_list, 3, extension3_->id()); 1609 InsertAddPinChange(&sync_list, 3, extension3_->id());
1619 SendPinChanges(sync_list, true); 1610 SendPinChanges(sync_list, true);
1620 1611
1621 // The model should only contain the browser shortcut and app list items. 1612 // The model should only contain the browser shortcut and app list items.
(...skipping 16 matching lines...) Expand all
1638 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1629 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1639 EXPECT_EQ("AppList, App1, Chrome, App2", GetPinnedAppStatus()); 1630 EXPECT_EQ("AppList, App1, Chrome, App2", GetPinnedAppStatus());
1640 1631
1641 // Installing |extension3_| should add it to the launcher - behind the 1632 // Installing |extension3_| should add it to the launcher - behind the
1642 // chrome icon, but in first location. 1633 // chrome icon, but in first location.
1643 extension_service_->AddExtension(extension3_.get()); 1634 extension_service_->AddExtension(extension3_.get());
1644 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus()); 1635 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus());
1645 } 1636 }
1646 1637
1647 // Check that syncing to a different state does the correct thing. 1638 // Check that syncing to a different state does the correct thing.
1648 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsResyncOrder) { 1639 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsResyncOrder) {
1649 InitLauncherController(); 1640 InitLauncherController();
1650 1641
1651 syncer::SyncChangeList sync_list0; 1642 syncer::SyncChangeList sync_list0;
1652 InsertAddPinChange(&sync_list0, 0, extension1_->id()); 1643 InsertAddPinChange(&sync_list0, 0, extension1_->id());
1653 InsertAddPinChange(&sync_list0, 1, extension2_->id()); 1644 InsertAddPinChange(&sync_list0, 1, extension2_->id());
1654 InsertAddPinChange(&sync_list0, 2, extension3_->id()); 1645 InsertAddPinChange(&sync_list0, 2, extension3_->id());
1655 SendPinChanges(sync_list0, true); 1646 SendPinChanges(sync_list0, true);
1656 1647
1657 // The shelf layout has always one static item at the beginning (App List). 1648 // The shelf layout has always one static item at the beginning (App List).
1658 extension_service_->AddExtension(extension2_.get()); 1649 extension_service_->AddExtension(extension2_.get());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 UnloadedExtensionInfo::REASON_UNINSTALL); 1687 UnloadedExtensionInfo::REASON_UNINSTALL);
1697 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1688 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1698 1689
1699 // Check that an update of an extension does not crash the system. 1690 // Check that an update of an extension does not crash the system.
1700 extension_service_->UnloadExtension(extension3_->id(), 1691 extension_service_->UnloadExtension(extension3_->id(),
1701 UnloadedExtensionInfo::REASON_UPDATE); 1692 UnloadedExtensionInfo::REASON_UPDATE);
1702 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1693 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1703 } 1694 }
1704 1695
1705 // Test the V1 app interaction flow: run it, activate it, close it. 1696 // Test the V1 app interaction flow: run it, activate it, close it.
1706 TEST_F(ChromeLauncherControllerImplTest, V1AppRunActivateClose) { 1697 TEST_F(ChromeLauncherControllerTest, V1AppRunActivateClose) {
1707 InitLauncherController(); 1698 InitLauncherController();
1708 // The model should only contain the browser shortcut and app list items. 1699 // The model should only contain the browser shortcut and app list items.
1709 EXPECT_EQ(2, model_->item_count()); 1700 EXPECT_EQ(2, model_->item_count());
1710 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1701 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1711 EXPECT_EQ(ash::kInvalidShelfID, 1702 EXPECT_EQ(ash::kInvalidShelfID,
1712 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1703 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1713 1704
1714 // Reporting that the app is running should create a new shelf item. 1705 // Reporting that the app is running should create a new shelf item.
1715 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1706 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1716 EXPECT_EQ(3, model_->item_count()); 1707 EXPECT_EQ(3, model_->item_count());
(...skipping 14 matching lines...) Expand all
1731 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1722 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1732 EXPECT_EQ(ash::kInvalidShelfID, 1723 EXPECT_EQ(ash::kInvalidShelfID,
1733 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1724 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1734 1725
1735 // Reporting that the app is closed again should have no effect. 1726 // Reporting that the app is closed again should have no effect.
1736 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); 1727 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1737 EXPECT_EQ(2, model_->item_count()); 1728 EXPECT_EQ(2, model_->item_count());
1738 } 1729 }
1739 1730
1740 // Test the V1 app interaction flow: pin it, run it, close it, unpin it. 1731 // Test the V1 app interaction flow: pin it, run it, close it, unpin it.
1741 TEST_F(ChromeLauncherControllerImplTest, V1AppPinRunCloseUnpin) { 1732 TEST_F(ChromeLauncherControllerTest, V1AppPinRunCloseUnpin) {
1742 InitLauncherController(); 1733 InitLauncherController();
1743 // The model should only contain the browser shortcut and app list items. 1734 // The model should only contain the browser shortcut and app list items.
1744 EXPECT_EQ(2, model_->item_count()); 1735 EXPECT_EQ(2, model_->item_count());
1745 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1736 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1746 EXPECT_EQ(ash::kInvalidShelfID, 1737 EXPECT_EQ(ash::kInvalidShelfID,
1747 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1738 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1748 1739
1749 // Pinning the app should create a new shelf item. 1740 // Pinning the app should create a new shelf item.
1750 launcher_controller_->PinAppWithID(extension1_->id()); 1741 launcher_controller_->PinAppWithID(extension1_->id());
1751 EXPECT_EQ(3, model_->item_count()); 1742 EXPECT_EQ(3, model_->item_count());
(...skipping 23 matching lines...) Expand all
1775 1766
1776 // Unpinning the app should remove its shelf item. 1767 // Unpinning the app should remove its shelf item.
1777 launcher_controller_->UnpinAppWithID(extension1_->id()); 1768 launcher_controller_->UnpinAppWithID(extension1_->id());
1778 EXPECT_EQ(2, model_->item_count()); 1769 EXPECT_EQ(2, model_->item_count());
1779 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1770 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1780 EXPECT_EQ(ash::kInvalidShelfID, 1771 EXPECT_EQ(ash::kInvalidShelfID,
1781 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1772 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1782 } 1773 }
1783 1774
1784 // Test the V1 app interaction flow: run it, pin it, close it, unpin it. 1775 // Test the V1 app interaction flow: run it, pin it, close it, unpin it.
1785 TEST_F(ChromeLauncherControllerImplTest, V1AppRunPinCloseUnpin) { 1776 TEST_F(ChromeLauncherControllerTest, V1AppRunPinCloseUnpin) {
1786 InitLauncherController(); 1777 InitLauncherController();
1787 // The model should only contain the browser shortcut and app list items. 1778 // The model should only contain the browser shortcut and app list items.
1788 EXPECT_EQ(2, model_->item_count()); 1779 EXPECT_EQ(2, model_->item_count());
1789 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1780 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1790 EXPECT_EQ(ash::kInvalidShelfID, 1781 EXPECT_EQ(ash::kInvalidShelfID,
1791 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1782 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1792 1783
1793 // Reporting that the app is running should create a new shelf item. 1784 // Reporting that the app is running should create a new shelf item.
1794 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1785 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1795 EXPECT_EQ(3, model_->item_count()); 1786 EXPECT_EQ(3, model_->item_count());
(...skipping 23 matching lines...) Expand all
1819 1810
1820 // Unpinning the app should remove its shelf item. 1811 // Unpinning the app should remove its shelf item.
1821 launcher_controller_->UnpinAppWithID(extension1_->id()); 1812 launcher_controller_->UnpinAppWithID(extension1_->id());
1822 EXPECT_EQ(2, model_->item_count()); 1813 EXPECT_EQ(2, model_->item_count());
1823 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1814 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1824 EXPECT_EQ(ash::kInvalidShelfID, 1815 EXPECT_EQ(ash::kInvalidShelfID,
1825 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1816 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1826 } 1817 }
1827 1818
1828 // Test the V1 app interaction flow: pin it, run it, unpin it, close it. 1819 // Test the V1 app interaction flow: pin it, run it, unpin it, close it.
1829 TEST_F(ChromeLauncherControllerImplTest, V1AppPinRunUnpinClose) { 1820 TEST_F(ChromeLauncherControllerTest, V1AppPinRunUnpinClose) {
1830 InitLauncherController(); 1821 InitLauncherController();
1831 // The model should only contain the browser shortcut and app list items. 1822 // The model should only contain the browser shortcut and app list items.
1832 EXPECT_EQ(2, model_->item_count()); 1823 EXPECT_EQ(2, model_->item_count());
1833 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1824 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1834 EXPECT_EQ(ash::kInvalidShelfID, 1825 EXPECT_EQ(ash::kInvalidShelfID,
1835 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1826 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1836 1827
1837 // Pinning the app should create a new shelf item. 1828 // Pinning the app should create a new shelf item.
1838 launcher_controller_->PinAppWithID(extension1_->id()); 1829 launcher_controller_->PinAppWithID(extension1_->id());
1839 EXPECT_EQ(3, model_->item_count()); 1830 EXPECT_EQ(3, model_->item_count());
(...skipping 23 matching lines...) Expand all
1863 1854
1864 // Reporting that the app is closed should remove its shelf item. 1855 // Reporting that the app is closed should remove its shelf item.
1865 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); 1856 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1866 EXPECT_EQ(2, model_->item_count()); 1857 EXPECT_EQ(2, model_->item_count());
1867 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1858 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1868 EXPECT_EQ(ash::kInvalidShelfID, 1859 EXPECT_EQ(ash::kInvalidShelfID,
1869 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1860 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1870 } 1861 }
1871 1862
1872 // Ensure unpinned V1 app ordering is properly restored after user changes. 1863 // Ensure unpinned V1 app ordering is properly restored after user changes.
1873 TEST_F(ChromeLauncherControllerImplTest, CheckRunningV1AppOrder) { 1864 TEST_F(ChromeLauncherControllerTest, CheckRunningV1AppOrder) {
1874 InitLauncherController(); 1865 InitLauncherController();
1875 // The model should only contain the browser shortcut and app list items. 1866 // The model should only contain the browser shortcut and app list items.
1876 EXPECT_EQ(2, model_->item_count()); 1867 EXPECT_EQ(2, model_->item_count());
1877 1868
1878 // Add a few running applications. 1869 // Add a few running applications.
1879 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1870 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1880 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_RUNNING); 1871 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_RUNNING);
1881 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_RUNNING); 1872 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_RUNNING);
1882 EXPECT_EQ(5, model_->item_count()); 1873 EXPECT_EQ(5, model_->item_count());
1883 // Note that this not only checks the order of applications but also the 1874 // Note that this not only checks the order of applications but also the
(...skipping 28 matching lines...) Expand all
1912 1903
1913 // Check that removing more items does not crash and changes nothing. 1904 // Check that removing more items does not crash and changes nothing.
1914 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_CLOSED); 1905 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_CLOSED);
1915 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1906 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1916 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); 1907 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus());
1917 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_CLOSED); 1908 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_CLOSED);
1918 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1909 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1919 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1910 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1920 } 1911 }
1921 1912
1922 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { 1913 TEST_P(ChromeLauncherControllerWithArcTest, ArcDeferredLaunch) {
1923 InitLauncherController(); 1914 InitLauncherController();
1924 1915
1925 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; 1916 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0];
1926 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; 1917 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1];
1927 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; 1918 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2];
1928 const arc::mojom::ShortcutInfo& shortcut = arc_test_.fake_shortcuts()[0]; 1919 const arc::mojom::ShortcutInfo& shortcut = arc_test_.fake_shortcuts()[0];
1929 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); 1920 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1);
1930 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); 1921 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2);
1931 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); 1922 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3);
1932 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut); 1923 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 arc_test_.app_instance()->launch_requests()[1].get(); 1993 arc_test_.app_instance()->launch_requests()[1].get();
2003 1994
2004 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || 1995 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) ||
2005 (request1->IsForApp(app3) && request2->IsForApp(app2))); 1996 (request1->IsForApp(app3) && request2->IsForApp(app2)));
2006 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(), 1997 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(),
2007 shortcut.intent_uri); 1998 shortcut.intent_uri);
2008 } 1999 }
2009 2000
2010 // Ensure the deferred controller does not override the active app controller 2001 // Ensure the deferred controller does not override the active app controller
2011 // (crbug.com/701152). 2002 // (crbug.com/701152).
2012 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) { 2003 TEST_P(ChromeLauncherControllerWithArcTest, ArcDeferredLaunchForActiveApp) {
2013 InitLauncherController(); 2004 InitLauncherController();
2014 SendListOfArcApps(); 2005 SendListOfArcApps();
2015 arc_test_.StopArcInstance(); 2006 arc_test_.StopArcInstance();
2016 2007
2017 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; 2008 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0];
2018 const std::string app_id = ArcAppTest::GetAppId(app); 2009 const std::string app_id = ArcAppTest::GetAppId(app);
2019 2010
2020 launcher_controller_->PinAppWithID(app_id); 2011 launcher_controller_->PinAppWithID(app_id);
2021 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 2012 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
2022 const ash::ShelfID shelf_id = 2013 const ash::ShelfID shelf_id =
(...skipping 25 matching lines...) Expand all
2048 item_index = model_->ItemIndexByID(shelf_id); 2039 item_index = model_->ItemIndexByID(shelf_id);
2049 ASSERT_GE(item_index, 0); 2040 ASSERT_GE(item_index, 0);
2050 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); 2041 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED);
2051 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP); 2042 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP);
2052 2043
2053 // Now launch request should not be ignored. 2044 // Now launch request should not be ignored.
2054 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); 2045 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
2055 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 2046 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
2056 } 2047 }
2057 2048
2058 TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { 2049 TEST_P(ChromeLauncherControllerMultiProfileWithArcTest, ArcMultiUser) {
2059 SendListOfArcApps(); 2050 SendListOfArcApps();
2060 2051
2061 InitLauncherController(); 2052 InitLauncherController();
2062 // TODO(crbug.com/654622): This test breaks with a non-null static instance. 2053 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2063 ChromeLauncherControllerImpl::set_instance_for_test(nullptr); 2054 ChromeLauncherController::set_instance_for_test(nullptr);
2064 2055
2065 SetLauncherControllerHelper(new TestLauncherControllerHelper); 2056 SetLauncherControllerHelper(new TestLauncherControllerHelper);
2066 2057
2067 // App1 exists all the time. 2058 // App1 exists all the time.
2068 // App2 is created when primary user is active and destroyed when secondary 2059 // App2 is created when primary user is active and destroyed when secondary
2069 // user is active. 2060 // user is active.
2070 // App3 created when secondary user is active. 2061 // App3 created when secondary user is active.
2071 2062
2072 const std::string user2 = "user2"; 2063 const std::string user2 = "user2";
2073 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2064 TestingProfile* profile2 = CreateMultiUserProfile(user2);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 EXPECT_EQ(ash::kInvalidShelfID, 2114 EXPECT_EQ(ash::kInvalidShelfID,
2124 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 2115 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2125 EXPECT_NE(ash::kInvalidShelfID, 2116 EXPECT_NE(ash::kInvalidShelfID,
2126 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 2117 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
2127 2118
2128 // Close active window to let test passes. 2119 // Close active window to let test passes.
2129 arc_window1->CloseNow(); 2120 arc_window1->CloseNow();
2130 arc_window3->CloseNow(); 2121 arc_window3->CloseNow();
2131 } 2122 }
2132 2123
2133 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { 2124 TEST_P(ChromeLauncherControllerWithArcTest, ArcRunningApp) {
2134 InitLauncherController(); 2125 InitLauncherController();
2135 2126
2136 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2127 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2137 SendListOfArcApps(); 2128 SendListOfArcApps();
2138 EXPECT_EQ(ash::kInvalidShelfID, 2129 EXPECT_EQ(ash::kInvalidShelfID,
2139 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2130 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2140 2131
2141 // Normal flow, create/destroy tasks. 2132 // Normal flow, create/destroy tasks.
2142 std::string window_app_id1("org.chromium.arc.1"); 2133 std::string window_app_id1("org.chromium.arc.1");
2143 std::string window_app_id2("org.chromium.arc.2"); 2134 std::string window_app_id2("org.chromium.arc.2");
(...skipping 22 matching lines...) Expand all
2166 EXPECT_NE(ash::kInvalidShelfID, 2157 EXPECT_NE(ash::kInvalidShelfID,
2167 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2158 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2168 arc_test_.StopArcInstance(); 2159 arc_test_.StopArcInstance();
2169 base::RunLoop().RunUntilIdle(); 2160 base::RunLoop().RunUntilIdle();
2170 EXPECT_EQ(ash::kInvalidShelfID, 2161 EXPECT_EQ(ash::kInvalidShelfID,
2171 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2162 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2172 } 2163 }
2173 2164
2174 // Test race creation/deletion of ARC app. 2165 // Test race creation/deletion of ARC app.
2175 // TODO(khmel): Remove after moving everything to wayland protocol. 2166 // TODO(khmel): Remove after moving everything to wayland protocol.
2176 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { 2167 TEST_P(ChromeLauncherControllerWithArcTest, ArcRaceCreateClose) {
2177 InitLauncherController(); 2168 InitLauncherController();
2178 2169
2179 const std::string arc_app_id1 = 2170 const std::string arc_app_id1 =
2180 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2171 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2181 const std::string arc_app_id2 = 2172 const std::string arc_app_id2 =
2182 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 2173 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
2183 SendListOfArcApps(); 2174 SendListOfArcApps();
2184 2175
2185 // ARC window created before and closed after mojom notification. 2176 // ARC window created before and closed after mojom notification.
2186 std::string window_app_id1("org.chromium.arc.1"); 2177 std::string window_app_id1("org.chromium.arc.1");
(...skipping 26 matching lines...) Expand all
2213 arc_window->Close(); 2204 arc_window->Close();
2214 base::RunLoop().RunUntilIdle(); 2205 base::RunLoop().RunUntilIdle();
2215 // Closing window does not close shelf item. It is closed on task destroy. 2206 // Closing window does not close shelf item. It is closed on task destroy.
2216 EXPECT_NE(ash::kInvalidShelfID, 2207 EXPECT_NE(ash::kInvalidShelfID,
2217 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 2208 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2218 arc_test_.app_instance()->SendTaskDestroyed(2); 2209 arc_test_.app_instance()->SendTaskDestroyed(2);
2219 EXPECT_EQ(ash::kInvalidShelfID, 2210 EXPECT_EQ(ash::kInvalidShelfID,
2220 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 2211 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2221 } 2212 }
2222 2213
2223 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { 2214 TEST_P(ChromeLauncherControllerWithArcTest, ArcWindowRecreation) {
2224 InitLauncherController(); 2215 InitLauncherController();
2225 2216
2226 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2217 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2227 SendListOfArcApps(); 2218 SendListOfArcApps();
2228 2219
2229 std::string window_app_id("org.chromium.arc.1"); 2220 std::string window_app_id("org.chromium.arc.1");
2230 views::Widget* arc_window = CreateArcWindow(window_app_id); 2221 views::Widget* arc_window = CreateArcWindow(window_app_id);
2231 ASSERT_TRUE(arc_window); 2222 ASSERT_TRUE(arc_window);
2232 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], 2223 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0],
2233 std::string()); 2224 std::string());
2234 const ash::ShelfID shelf_id = 2225 const ash::ShelfID shelf_id =
2235 launcher_controller_->GetShelfIDForAppID(arc_app_id); 2226 launcher_controller_->GetShelfIDForAppID(arc_app_id);
2236 EXPECT_NE(ash::kInvalidShelfID, shelf_id); 2227 EXPECT_NE(ash::kInvalidShelfID, shelf_id);
2237 2228
2238 for (int i = 0; i < 3; ++i) { 2229 for (int i = 0; i < 3; ++i) {
2239 arc_window->Close(); 2230 arc_window->Close();
2240 base::RunLoop().RunUntilIdle(); 2231 base::RunLoop().RunUntilIdle();
2241 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2232 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
2242 2233
2243 arc_window = CreateArcWindow(window_app_id); 2234 arc_window = CreateArcWindow(window_app_id);
2244 ASSERT_TRUE(arc_window); 2235 ASSERT_TRUE(arc_window);
2245 base::RunLoop().RunUntilIdle(); 2236 base::RunLoop().RunUntilIdle();
2246 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2237 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
2247 } 2238 }
2248 } 2239 }
2249 2240
2250 // Validate that ARC app is pinned correctly and pin is removed automatically 2241 // Validate that ARC app is pinned correctly and pin is removed automatically
2251 // once app is uninstalled. 2242 // once app is uninstalled.
2252 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { 2243 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPin) {
2253 InitLauncherController(); 2244 InitLauncherController();
2254 2245
2255 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2246 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2256 2247
2257 SendListOfArcApps(); 2248 SendListOfArcApps();
2258 extension_service_->AddExtension(extension1_.get()); 2249 extension_service_->AddExtension(extension1_.get());
2259 extension_service_->AddExtension(extension2_.get()); 2250 extension_service_->AddExtension(extension2_.get());
2260 2251
2261 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 2252 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
2262 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); 2253 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id));
(...skipping 24 matching lines...) Expand all
2287 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 2278 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
2288 EnablePlayStore(false); 2279 EnablePlayStore(false);
2289 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 2280 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
2290 EnablePlayStore(true); 2281 EnablePlayStore(true);
2291 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 2282 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
2292 SendListOfArcApps(); 2283 SendListOfArcApps();
2293 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 2284 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
2294 } 2285 }
2295 2286
2296 // Validates that ARC app pins persist across OptOut/OptIn. 2287 // Validates that ARC app pins persist across OptOut/OptIn.
2297 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { 2288 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPinOptOutOptIn) {
2298 InitLauncherController(); 2289 InitLauncherController();
2299 2290
2300 const std::string arc_app_id1 = 2291 const std::string arc_app_id1 =
2301 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2292 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2302 const std::string arc_app_id2 = 2293 const std::string arc_app_id2 =
2303 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 2294 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
2304 2295
2305 SendListOfArcApps(); 2296 SendListOfArcApps();
2306 extension_service_->AddExtension(extension1_.get()); 2297 extension_service_->AddExtension(extension1_.get());
2307 extension_service_->AddExtension(extension2_.get()); 2298 extension_service_->AddExtension(extension2_.get());
(...skipping 29 matching lines...) Expand all
2337 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); 2328 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
2338 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 2329 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2339 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); 2330 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2));
2340 2331
2341 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", 2332 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
2342 GetPinnedAppStatus()); 2333 GetPinnedAppStatus());
2343 } 2334 }
2344 2335
2345 // Check that with multi profile V1 apps are properly added / removed from the 2336 // Check that with multi profile V1 apps are properly added / removed from the
2346 // shelf. 2337 // shelf.
2347 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2338 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2348 V1AppUpdateOnUserSwitch) { 2339 V1AppUpdateOnUserSwitch) {
2349 // Create a browser item in the LauncherController. 2340 // Create a browser item in the LauncherController.
2350 InitLauncherController(); 2341 InitLauncherController();
2351 2342
2352 EXPECT_EQ(2, model_->item_count()); 2343 EXPECT_EQ(2, model_->item_count());
2353 { 2344 {
2354 // Create a "windowed gmail app". 2345 // Create a "windowed gmail app".
2355 std::unique_ptr<V1App> v1_app( 2346 std::unique_ptr<V1App> v1_app(
2356 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); 2347 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url));
2357 EXPECT_EQ(3, model_->item_count()); 2348 EXPECT_EQ(3, model_->item_count());
(...skipping 10 matching lines...) Expand all
2368 2359
2369 // After switching back the item should be back. 2360 // After switching back the item should be back.
2370 SwitchActiveUser(account_id); 2361 SwitchActiveUser(account_id);
2371 EXPECT_EQ(3, model_->item_count()); 2362 EXPECT_EQ(3, model_->item_count());
2372 // Note we destroy now the gmail app with the closure end. 2363 // Note we destroy now the gmail app with the closure end.
2373 } 2364 }
2374 EXPECT_EQ(2, model_->item_count()); 2365 EXPECT_EQ(2, model_->item_count());
2375 } 2366 }
2376 2367
2377 // Check edge cases with multi profile V1 apps in the shelf. 2368 // Check edge cases with multi profile V1 apps in the shelf.
2378 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2369 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2379 V1AppUpdateOnUserSwitchEdgecases) { 2370 V1AppUpdateOnUserSwitchEdgecases) {
2380 // Create a browser item in the LauncherController. 2371 // Create a browser item in the LauncherController.
2381 InitLauncherController(); 2372 InitLauncherController();
2382 2373
2383 // First test: Create an app when the user is not active. 2374 // First test: Create an app when the user is not active.
2384 std::string user2 = "user2"; 2375 std::string user2 = "user2";
2385 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2376 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2386 const AccountId account_id2( 2377 const AccountId account_id2(
2387 multi_user_util::GetAccountIdFromProfile(profile2)); 2378 multi_user_util::GetAccountIdFromProfile(profile2));
2388 const AccountId account_id( 2379 const AccountId account_id(
(...skipping 15 matching lines...) Expand all
2404 // Note: the closure ends and the browser will go away. 2395 // Note: the closure ends and the browser will go away.
2405 } 2396 }
2406 EXPECT_EQ(2, model_->item_count()); 2397 EXPECT_EQ(2, model_->item_count());
2407 SwitchActiveUser(account_id2); 2398 SwitchActiveUser(account_id2);
2408 EXPECT_EQ(2, model_->item_count()); 2399 EXPECT_EQ(2, model_->item_count());
2409 SwitchActiveUser(account_id); 2400 SwitchActiveUser(account_id);
2410 EXPECT_EQ(2, model_->item_count()); 2401 EXPECT_EQ(2, model_->item_count());
2411 } 2402 }
2412 2403
2413 // Check edge case where a visiting V1 app gets closed (crbug.com/321374). 2404 // Check edge case where a visiting V1 app gets closed (crbug.com/321374).
2414 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2405 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2415 V1CloseOnVisitingDesktop) { 2406 V1CloseOnVisitingDesktop) {
2416 // Create a browser item in the LauncherController. 2407 // Create a browser item in the LauncherController.
2417 InitLauncherController(); 2408 InitLauncherController();
2418 2409
2419 chrome::MultiUserWindowManager* manager = 2410 chrome::MultiUserWindowManager* manager =
2420 chrome::MultiUserWindowManager::GetInstance(); 2411 chrome::MultiUserWindowManager::GetInstance();
2421 2412
2422 // First create an app when the user is active. 2413 // First create an app when the user is active.
2423 std::string user2 = "user2"; 2414 std::string user2 = "user2";
2424 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2415 TestingProfile* profile2 = CreateMultiUserProfile(user2);
(...skipping 23 matching lines...) Expand all
2448 // Create a "windowed gmail app". 2439 // Create a "windowed gmail app".
2449 std::unique_ptr<V1App> v1_app(CreateRunningV1App( 2440 std::unique_ptr<V1App> v1_app(CreateRunningV1App(
2450 profile(), extension_misc::kGmailAppId, kGmailLaunchURL)); 2441 profile(), extension_misc::kGmailAppId, kGmailLaunchURL));
2451 EXPECT_EQ(3, model_->item_count()); 2442 EXPECT_EQ(3, model_->item_count());
2452 } 2443 }
2453 SwitchActiveUser(account_id2); 2444 SwitchActiveUser(account_id2);
2454 EXPECT_EQ(2, model_->item_count()); 2445 EXPECT_EQ(2, model_->item_count());
2455 } 2446 }
2456 2447
2457 // Check edge cases with multi profile V1 apps in the shelf. 2448 // Check edge cases with multi profile V1 apps in the shelf.
2458 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2449 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2459 V1AppUpdateOnUserSwitchEdgecases2) { 2450 V1AppUpdateOnUserSwitchEdgecases2) {
2460 // Create a browser item in the LauncherController. 2451 // Create a browser item in the LauncherController.
2461 InitLauncherController(); 2452 InitLauncherController();
2462 2453
2463 // First test: Create an app when the user is not active. 2454 // First test: Create an app when the user is not active.
2464 std::string user2 = "user2"; 2455 std::string user2 = "user2";
2465 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2456 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2466 const AccountId account_id( 2457 const AccountId account_id(
2467 multi_user_util::GetAccountIdFromProfile(profile())); 2458 multi_user_util::GetAccountIdFromProfile(profile()));
2468 const AccountId account_id2( 2459 const AccountId account_id2(
(...skipping 17 matching lines...) Expand all
2486 } 2477 }
2487 EXPECT_EQ(2, model_->item_count()); 2478 EXPECT_EQ(2, model_->item_count());
2488 SwitchActiveUser(account_id); 2479 SwitchActiveUser(account_id);
2489 EXPECT_EQ(2, model_->item_count()); 2480 EXPECT_EQ(2, model_->item_count());
2490 SwitchActiveUser(account_id2); 2481 SwitchActiveUser(account_id2);
2491 EXPECT_EQ(2, model_->item_count()); 2482 EXPECT_EQ(2, model_->item_count());
2492 } 2483 }
2493 2484
2494 // Check that activating an item which is on another user's desktop, will bring 2485 // Check that activating an item which is on another user's desktop, will bring
2495 // it back. 2486 // it back.
2496 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2487 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2497 TestLauncherActivationPullsBackWindow) { 2488 TestLauncherActivationPullsBackWindow) {
2498 // Create a browser item in the LauncherController. 2489 // Create a browser item in the LauncherController.
2499 InitLauncherController(); 2490 InitLauncherController();
2500 chrome::MultiUserWindowManager* manager = 2491 chrome::MultiUserWindowManager* manager =
2501 chrome::MultiUserWindowManager::GetInstance(); 2492 chrome::MultiUserWindowManager::GetInstance();
2502 2493
2503 // Create a second test profile. The first is the one in profile() created in 2494 // Create a second test profile. The first is the one in profile() created in
2504 // BrowserWithTestWindowTest::SetUp(). 2495 // BrowserWithTestWindowTest::SetUp().
2505 // No need to add the profiles to the MultiUserWindowManager here. 2496 // No need to add the profiles to the MultiUserWindowManager here.
2506 // CreateMultiUserProfile() already does that. 2497 // CreateMultiUserProfile() already does that.
(...skipping 17 matching lines...) Expand all
2524 // does pull it back to that user. 2515 // does pull it back to that user.
2525 manager->ShowWindowForUser( 2516 manager->ShowWindowForUser(
2526 window, multi_user_util::GetAccountIdFromProfile(profile2)); 2517 window, multi_user_util::GetAccountIdFromProfile(profile2));
2527 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user)); 2518 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user));
2528 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); 2519 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false);
2529 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); 2520 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user));
2530 } 2521 }
2531 2522
2532 // Check that a running windowed V1 application will be properly pinned and 2523 // Check that a running windowed V1 application will be properly pinned and
2533 // unpinned when the order gets changed through a profile / policy change. 2524 // unpinned when the order gets changed through a profile / policy change.
2534 TEST_F(ChromeLauncherControllerImplTest, 2525 TEST_F(ChromeLauncherControllerTest,
2535 RestoreDefaultAndRunningV1AppsResyncOrder) { 2526 RestoreDefaultAndRunningV1AppsResyncOrder) {
2536 InitLauncherController(); 2527 InitLauncherController();
2537 2528
2538 syncer::SyncChangeList sync_list; 2529 syncer::SyncChangeList sync_list;
2539 InsertAddPinChange(&sync_list, 0, extension1_->id()); 2530 InsertAddPinChange(&sync_list, 0, extension1_->id());
2540 InsertAddPinChange(&sync_list, 1, extension3_->id()); 2531 InsertAddPinChange(&sync_list, 1, extension3_->id());
2541 SendPinChanges(sync_list, true); 2532 SendPinChanges(sync_list, true);
2542 2533
2543 // The shelf layout has always one static item at the beginning (App List). 2534 // The shelf layout has always one static item at the beginning (App List).
2544 extension_service_->AddExtension(extension1_.get()); 2535 extension_service_->AddExtension(extension1_.get());
(...skipping 25 matching lines...) Expand all
2570 SendPinChanges(sync_list2, true); 2561 SendPinChanges(sync_list2, true);
2571 EXPECT_EQ("AppList, Chrome, App3, App1, app2", GetPinnedAppStatus()); 2562 EXPECT_EQ("AppList, Chrome, App3, App1, app2", GetPinnedAppStatus());
2572 2563
2573 // Removing an item should simply close it and everything should shift. 2564 // Removing an item should simply close it and everything should shift.
2574 SendPinChanges(syncer::SyncChangeList(), true); 2565 SendPinChanges(syncer::SyncChangeList(), true);
2575 EXPECT_EQ("AppList, Chrome, App3, app2", GetPinnedAppStatus()); 2566 EXPECT_EQ("AppList, Chrome, App3, app2", GetPinnedAppStatus());
2576 } 2567 }
2577 2568
2578 // Check that a running unpinned V2 application will be properly pinned and 2569 // Check that a running unpinned V2 application will be properly pinned and
2579 // unpinned when the order gets changed through a profile / policy change. 2570 // unpinned when the order gets changed through a profile / policy change.
2580 TEST_F(ChromeLauncherControllerImplTest, 2571 TEST_F(ChromeLauncherControllerTest,
2581 RestoreDefaultAndRunningV2AppsResyncOrder) { 2572 RestoreDefaultAndRunningV2AppsResyncOrder) {
2582 InitLauncherController(); 2573 InitLauncherController();
2583 syncer::SyncChangeList sync_list0; 2574 syncer::SyncChangeList sync_list0;
2584 InsertAddPinChange(&sync_list0, 0, extension1_->id()); 2575 InsertAddPinChange(&sync_list0, 0, extension1_->id());
2585 InsertAddPinChange(&sync_list0, 1, extension3_->id()); 2576 InsertAddPinChange(&sync_list0, 1, extension3_->id());
2586 SendPinChanges(sync_list0, true); 2577 SendPinChanges(sync_list0, true);
2587 // The shelf layout has always one static item at the beginning (app List). 2578 // The shelf layout has always one static item at the beginning (app List).
2588 extension_service_->AddExtension(extension1_.get()); 2579 extension_service_->AddExtension(extension1_.get());
2589 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 2580 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
2590 extension_service_->AddExtension(extension_platform_app_.get()); 2581 extension_service_->AddExtension(extension_platform_app_.get());
(...skipping 24 matching lines...) Expand all
2615 2606
2616 // Removing an item should simply close it and everything should shift. 2607 // Removing an item should simply close it and everything should shift.
2617 syncer::SyncChangeList sync_list3; 2608 syncer::SyncChangeList sync_list3;
2618 InsertAddPinChange(&sync_list3, 0, extension3_->id()); 2609 InsertAddPinChange(&sync_list3, 0, extension3_->id());
2619 SendPinChanges(sync_list3, true); 2610 SendPinChanges(sync_list3, true);
2620 EXPECT_EQ("AppList, Chrome, App3, *platform_app", GetPinnedAppStatus()); 2611 EXPECT_EQ("AppList, Chrome, App3, *platform_app", GetPinnedAppStatus());
2621 } 2612 }
2622 2613
2623 // Each user has a different set of applications pinned. Check that when 2614 // Each user has a different set of applications pinned. Check that when
2624 // switching between the two users, the state gets properly set. 2615 // switching between the two users, the state gets properly set.
2625 TEST_F(ChromeLauncherControllerImplTest, UserSwitchIconRestore) { 2616 TEST_F(ChromeLauncherControllerTest, UserSwitchIconRestore) {
2626 syncer::SyncChangeList user_a; 2617 syncer::SyncChangeList user_a;
2627 syncer::SyncChangeList user_b; 2618 syncer::SyncChangeList user_b;
2628 2619
2629 SetUpMultiUserScenario(&user_a, &user_b); 2620 SetUpMultiUserScenario(&user_a, &user_b);
2630 2621
2631 // Show user 1. 2622 // Show user 1.
2632 SendPinChanges(user_a, true); 2623 SendPinChanges(user_a, true);
2633 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", 2624 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome",
2634 GetPinnedAppStatus()); 2625 GetPinnedAppStatus());
2635 2626
2636 // Show user 2. 2627 // Show user 2.
2637 SendPinChanges(user_b, true); 2628 SendPinChanges(user_b, true);
2638 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus()); 2629 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus());
2639 2630
2640 // Switch back to 1. 2631 // Switch back to 1.
2641 SendPinChanges(user_a, true); 2632 SendPinChanges(user_a, true);
2642 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", 2633 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome",
2643 GetPinnedAppStatus()); 2634 GetPinnedAppStatus());
2644 2635
2645 // Switch back to 2. 2636 // Switch back to 2.
2646 SendPinChanges(user_b, true); 2637 SendPinChanges(user_b, true);
2647 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus()); 2638 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus());
2648 } 2639 }
2649 2640
2650 // Each user has a different set of applications pinned, and one user has an 2641 // Each user has a different set of applications pinned, and one user has an
2651 // application running. Check that when switching between the two users, the 2642 // application running. Check that when switching between the two users, the
2652 // state gets properly set. 2643 // state gets properly set.
2653 TEST_F(ChromeLauncherControllerImplTest, 2644 TEST_F(ChromeLauncherControllerTest, UserSwitchIconRestoreWithRunningV2App) {
2654 UserSwitchIconRestoreWithRunningV2App) {
2655 syncer::SyncChangeList user_a; 2645 syncer::SyncChangeList user_a;
2656 syncer::SyncChangeList user_b; 2646 syncer::SyncChangeList user_b;
2657 2647
2658 SetUpMultiUserScenario(&user_a, &user_b); 2648 SetUpMultiUserScenario(&user_a, &user_b);
2659 2649
2660 // Run the platform (V2) app. 2650 // Run the platform (V2) app.
2661 CreateRunningV2App(extension_platform_app_->id()); 2651 CreateRunningV2App(extension_platform_app_->id());
2662 2652
2663 // Show user 1. 2653 // Show user 1.
2664 SendPinChanges(user_a, true); 2654 SendPinChanges(user_a, true);
(...skipping 13 matching lines...) Expand all
2678 // Switch back to 2. 2668 // Switch back to 2.
2679 SendPinChanges(user_b, true); 2669 SendPinChanges(user_b, true);
2680 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", 2670 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app",
2681 GetPinnedAppStatus()); 2671 GetPinnedAppStatus());
2682 } 2672 }
2683 2673
2684 // Each user has a different set of applications pinned, and one user has an 2674 // Each user has a different set of applications pinned, and one user has an
2685 // application running. The chrome icon is not the last item in the list. 2675 // application running. The chrome icon is not the last item in the list.
2686 // Check that when switching between the two users, the state gets properly set. 2676 // Check that when switching between the two users, the state gets properly set.
2687 // There was once a bug associated with this. 2677 // There was once a bug associated with this.
2688 TEST_F(ChromeLauncherControllerImplTest, 2678 TEST_F(ChromeLauncherControllerTest,
2689 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) { 2679 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) {
2690 syncer::SyncChangeList user_a; 2680 syncer::SyncChangeList user_a;
2691 syncer::SyncChangeList user_b; 2681 syncer::SyncChangeList user_b;
2692 SetUpMultiUserScenario(&user_a, &user_b); 2682 SetUpMultiUserScenario(&user_a, &user_b);
2693 2683
2694 // Run the platform (V2) app. 2684 // Run the platform (V2) app.
2695 CreateRunningV2App(extension_platform_app_->id()); 2685 CreateRunningV2App(extension_platform_app_->id());
2696 2686
2697 // Show user 1. 2687 // Show user 1.
2698 SendPinChanges(user_a, true); 2688 SendPinChanges(user_a, true);
2699 SetShelfChromeIconIndex(5); 2689 SetShelfChromeIconIndex(5);
2700 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5", 2690 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5",
2701 GetPinnedAppStatus()); 2691 GetPinnedAppStatus());
2702 2692
2703 // Show user 2. 2693 // Show user 2.
2704 SendPinChanges(user_b, true); 2694 SendPinChanges(user_b, true);
2705 SetShelfChromeIconIndex(4); 2695 SetShelfChromeIconIndex(4);
2706 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", 2696 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app",
2707 GetPinnedAppStatus()); 2697 GetPinnedAppStatus());
2708 2698
2709 // Switch back to 1. 2699 // Switch back to 1.
2710 SendPinChanges(user_a, true); 2700 SendPinChanges(user_a, true);
2711 SetShelfChromeIconIndex(5); 2701 SetShelfChromeIconIndex(5);
2712 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5", 2702 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5",
2713 GetPinnedAppStatus()); 2703 GetPinnedAppStatus());
2714 } 2704 }
2715 2705
2716 TEST_F(ChromeLauncherControllerImplTest, Policy) { 2706 TEST_F(ChromeLauncherControllerTest, Policy) {
2717 extension_service_->AddExtension(extension1_.get()); 2707 extension_service_->AddExtension(extension1_.get());
2718 extension_service_->AddExtension(extension3_.get()); 2708 extension_service_->AddExtension(extension3_.get());
2719 2709
2720 InitLauncherController(); 2710 InitLauncherController();
2721 2711
2722 syncer::SyncChangeList sync_list; 2712 syncer::SyncChangeList sync_list;
2723 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); 2713 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId);
2724 SendPinChanges(sync_list, true); 2714 SendPinChanges(sync_list, true);
2725 2715
2726 base::ListValue policy_value; 2716 base::ListValue policy_value;
(...skipping 25 matching lines...) Expand all
2752 policy_value.Remove(0, NULL); 2742 policy_value.Remove(0, NULL);
2753 profile()->GetTestingPrefService()->SetManagedPref( 2743 profile()->GetTestingPrefService()->SetManagedPref(
2754 prefs::kPolicyPinnedLauncherApps, policy_value.CreateDeepCopy()); 2744 prefs::kPolicyPinnedLauncherApps, policy_value.CreateDeepCopy());
2755 EXPECT_EQ(4, model_->item_count()); 2745 EXPECT_EQ(4, model_->item_count());
2756 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 2746 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
2757 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 2747 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
2758 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 2748 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2759 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 2749 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
2760 } 2750 }
2761 2751
2762 TEST_F(ChromeLauncherControllerImplTest, UnpinWithUninstall) { 2752 TEST_F(ChromeLauncherControllerTest, UnpinWithUninstall) {
2763 extension_service_->AddExtension(extension3_.get()); 2753 extension_service_->AddExtension(extension3_.get());
2764 extension_service_->AddExtension(extension4_.get()); 2754 extension_service_->AddExtension(extension4_.get());
2765 2755
2766 InitLauncherController(); 2756 InitLauncherController();
2767 2757
2768 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 2758 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
2769 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); 2759 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
2770 2760
2771 extension_service_->UnloadExtension(extension3_->id(), 2761 extension_service_->UnloadExtension(extension3_->id(),
2772 UnloadedExtensionInfo::REASON_UNINSTALL); 2762 UnloadedExtensionInfo::REASON_UNINSTALL);
2773 2763
2774 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 2764 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
2775 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); 2765 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
2776 } 2766 }
2777 2767
2778 TEST_F(ChromeLauncherControllerImplTest, SyncUpdates) { 2768 TEST_F(ChromeLauncherControllerTest, SyncUpdates) {
2779 extension_service_->AddExtension(extension2_.get()); 2769 extension_service_->AddExtension(extension2_.get());
2780 extension_service_->AddExtension(extension3_.get()); 2770 extension_service_->AddExtension(extension3_.get());
2781 extension_service_->AddExtension(extension4_.get()); 2771 extension_service_->AddExtension(extension4_.get());
2782 2772
2783 InitLauncherController(); 2773 InitLauncherController();
2784 2774
2785 syncer::SyncChangeList sync_list; 2775 syncer::SyncChangeList sync_list;
2786 InsertAddPinChange(&sync_list, 10, extension_misc::kChromeAppId); 2776 InsertAddPinChange(&sync_list, 10, extension_misc::kChromeAppId);
2787 SendPinChanges(sync_list, true); 2777 SendPinChanges(sync_list, true);
2788 2778
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2836 2826
2837 sync_list.clear(); 2827 sync_list.clear();
2838 InsertRemovePinChange(&sync_list, extension3_->id()); 2828 InsertRemovePinChange(&sync_list, extension3_->id());
2839 InsertRemovePinChange(&sync_list, extension2_->id()); 2829 InsertRemovePinChange(&sync_list, extension2_->id());
2840 SendPinChanges(sync_list, false); 2830 SendPinChanges(sync_list, false);
2841 expected_pinned_apps.clear(); 2831 expected_pinned_apps.clear();
2842 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps); 2832 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2843 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps); 2833 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2844 } 2834 }
2845 2835
2846 TEST_F(ChromeLauncherControllerImplTest, ImportLegacyPin) { 2836 TEST_F(ChromeLauncherControllerTest, ImportLegacyPin) {
2847 // Note extension3_ is actually Gmail app which is default pinned. 2837 // Note extension3_ is actually Gmail app which is default pinned.
2848 extension_service_->AddExtension(extension3_.get()); 2838 extension_service_->AddExtension(extension3_.get());
2849 InitLauncherController(); 2839 InitLauncherController();
2850 2840
2851 // Default pins should contain Gmail. Pref is not syncing now. 2841 // Default pins should contain Gmail. Pref is not syncing now.
2852 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 2842 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
2853 2843
2854 extension_service_->AddExtension(extension2_.get()); 2844 extension_service_->AddExtension(extension2_.get());
2855 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 2845 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
2856 2846
(...skipping 26 matching lines...) Expand all
2883 StartPrefSyncServiceForPins(value); 2873 StartPrefSyncServiceForPins(value);
2884 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); 2874 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus());
2885 2875
2886 // Next Chrome start should preserve pins. 2876 // Next Chrome start should preserve pins.
2887 RecreateLauncherController()->Init(); 2877 RecreateLauncherController()->Init();
2888 StopPrefSyncService(); 2878 StopPrefSyncService();
2889 StartPrefSyncService(syncer::SyncDataList()); 2879 StartPrefSyncService(syncer::SyncDataList());
2890 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); 2880 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus());
2891 } 2881 }
2892 2882
2893 TEST_F(ChromeLauncherControllerImplTest, PendingInsertionOrder) { 2883 TEST_F(ChromeLauncherControllerTest, PendingInsertionOrder) {
2894 extension_service_->AddExtension(extension1_.get()); 2884 extension_service_->AddExtension(extension1_.get());
2895 extension_service_->AddExtension(extension3_.get()); 2885 extension_service_->AddExtension(extension3_.get());
2896 2886
2897 InitLauncherController(); 2887 InitLauncherController();
2898 2888
2899 syncer::SyncChangeList sync_list; 2889 syncer::SyncChangeList sync_list;
2900 InsertAddPinChange(&sync_list, 0, extension1_->id()); 2890 InsertAddPinChange(&sync_list, 0, extension1_->id());
2901 InsertAddPinChange(&sync_list, 1, extension2_->id()); 2891 InsertAddPinChange(&sync_list, 1, extension2_->id());
2902 InsertAddPinChange(&sync_list, 2, extension3_->id()); 2892 InsertAddPinChange(&sync_list, 2, extension3_->id());
2903 SendPinChanges(sync_list, true); 2893 SendPinChanges(sync_list, true);
2904 2894
2905 std::vector<std::string> expected_pinned_apps; 2895 std::vector<std::string> expected_pinned_apps;
2906 expected_pinned_apps.push_back(extension1_->id()); 2896 expected_pinned_apps.push_back(extension1_->id());
2907 expected_pinned_apps.push_back(extension3_->id()); 2897 expected_pinned_apps.push_back(extension3_->id());
2908 std::vector<std::string> actual_pinned_apps; 2898 std::vector<std::string> actual_pinned_apps;
2909 2899
2910 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps); 2900 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2911 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps); 2901 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2912 2902
2913 // Install |extension2| and verify it shows up between the other two. 2903 // Install |extension2| and verify it shows up between the other two.
2914 extension_service_->AddExtension(extension2_.get()); 2904 extension_service_->AddExtension(extension2_.get());
2915 expected_pinned_apps.insert(expected_pinned_apps.begin() + 1, 2905 expected_pinned_apps.insert(expected_pinned_apps.begin() + 1,
2916 extension2_->id()); 2906 extension2_->id());
2917 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps); 2907 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2918 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps); 2908 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2919 } 2909 }
2920 2910
2921 // Ensure |controller| creates the expected menu items for the given shelf item. 2911 // Ensure |controller| creates the expected menu items for the given shelf item.
2922 void CheckAppMenu(ChromeLauncherControllerImpl* controller, 2912 void CheckAppMenu(ChromeLauncherController* controller,
2923 const ash::ShelfItem& item, 2913 const ash::ShelfItem& item,
2924 size_t expected_item_count, 2914 size_t expected_item_count,
2925 base::string16 expected_item_titles[]) { 2915 base::string16 expected_item_titles[]) {
2926 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item); 2916 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item);
2927 ASSERT_EQ(expected_item_count, items.size()); 2917 ASSERT_EQ(expected_item_count, items.size());
2928 for (size_t i = 0; i < expected_item_count; i++) 2918 for (size_t i = 0; i < expected_item_count; i++)
2929 EXPECT_EQ(expected_item_titles[i], items[i]->label); 2919 EXPECT_EQ(expected_item_titles[i], items[i]->label);
2930 } 2920 }
2931 2921
2932 // Check that browsers get reflected correctly in the launcher menu. 2922 // Check that browsers get reflected correctly in the launcher menu.
2933 TEST_F(ChromeLauncherControllerImplTest, BrowserMenuGeneration) { 2923 TEST_F(ChromeLauncherControllerTest, BrowserMenuGeneration) {
2934 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 2924 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
2935 chrome::NewTab(browser()); 2925 chrome::NewTab(browser());
2936 2926
2937 InitLauncherController(); 2927 InitLauncherController();
2938 2928
2939 // Check that the browser list is empty at this time. 2929 // Check that the browser list is empty at this time.
2940 ash::ShelfItem item_browser; 2930 ash::ShelfItem item_browser;
2941 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 2931 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
2942 item_browser.id = 2932 item_browser.id =
2943 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); 2933 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId);
2944 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); 2934 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr);
2945 2935
2946 // Now make the created browser() visible by showing its browser window. 2936 // Now make the created browser() visible by showing its browser window.
2947 browser()->window()->Show(); 2937 browser()->window()->Show();
2948 base::string16 title1 = ASCIIToUTF16("Test1"); 2938 base::string16 title1 = ASCIIToUTF16("Test1");
2949 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); 2939 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1);
2950 base::string16 one_menu_item[] = { title1 }; 2940 base::string16 one_menu_item[] = {title1};
2951 2941
2952 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item); 2942 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item);
2953 2943
2954 // Create one more browser/window and check that one more was added. 2944 // Create one more browser/window and check that one more was added.
2955 std::unique_ptr<Browser> browser2( 2945 std::unique_ptr<Browser> browser2(
2956 CreateBrowserWithTestWindowForProfile(profile())); 2946 CreateBrowserWithTestWindowForProfile(profile()));
2957 chrome::NewTab(browser2.get()); 2947 chrome::NewTab(browser2.get());
2958 browser2->window()->Show(); 2948 browser2->window()->Show();
2959 base::string16 title2 = ASCIIToUTF16("Test2"); 2949 base::string16 title2 = ASCIIToUTF16("Test2");
2960 NavigateAndCommitActiveTabWithTitle(browser2.get(), GURL("http://test2"), 2950 NavigateAndCommitActiveTabWithTitle(browser2.get(), GURL("http://test2"),
2961 title2); 2951 title2);
2962 2952
2963 // Check that the list contains now two entries - make furthermore sure that 2953 // Check that the list contains now two entries - make furthermore sure that
2964 // the active item is the first entry. 2954 // the active item is the first entry.
2965 base::string16 two_menu_items[] = {title1, title2}; 2955 base::string16 two_menu_items[] = {title1, title2};
2966 CheckAppMenu(launcher_controller_, item_browser, 2, two_menu_items); 2956 CheckAppMenu(launcher_controller_, item_browser, 2, two_menu_items);
2967 2957
2968 // Apparently we have to close all tabs we have. 2958 // Apparently we have to close all tabs we have.
2969 chrome::CloseTab(browser2.get()); 2959 chrome::CloseTab(browser2.get());
2970 } 2960 }
2971 2961
2972 // Check the multi profile case where only user related browsers should show up. 2962 // Check the multi profile case where only user related browsers should show up.
2973 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2963 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2974 BrowserMenuGenerationTwoUsers) { 2964 BrowserMenuGenerationTwoUsers) {
2975 // Create a browser item in the LauncherController. 2965 // Create a browser item in the LauncherController.
2976 InitLauncherController(); 2966 InitLauncherController();
2977 2967
2978 ash::ShelfItem item_browser; 2968 ash::ShelfItem item_browser;
2979 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 2969 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
2980 item_browser.id = 2970 item_browser.id =
2981 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); 2971 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId);
2982 2972
2983 // Check that the menu is empty. 2973 // Check that the menu is empty.
2984 chrome::NewTab(browser()); 2974 chrome::NewTab(browser());
2985 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); 2975 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr);
2986 2976
2987 // Show the created |browser()| by showing its window. 2977 // Show the created |browser()| by showing its window.
2988 browser()->window()->Show(); 2978 browser()->window()->Show();
2989 base::string16 title1 = ASCIIToUTF16("Test1"); 2979 base::string16 title1 = ASCIIToUTF16("Test1");
2990 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); 2980 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1);
2991 base::string16 one_menu_item1[] = { title1 }; 2981 base::string16 one_menu_item1[] = {title1};
2992 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1); 2982 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1);
2993 2983
2994 // Create a browser for another user and check that it is not included in the 2984 // Create a browser for another user and check that it is not included in the
2995 // users running browser list. 2985 // users running browser list.
2996 std::string user2 = "user2"; 2986 std::string user2 = "user2";
2997 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2987 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2998 const AccountId account_id2( 2988 const AccountId account_id2(
2999 multi_user_util::GetAccountIdFromProfile(profile2)); 2989 multi_user_util::GetAccountIdFromProfile(profile2));
3000 std::unique_ptr<Browser> browser2( 2990 std::unique_ptr<Browser> browser2(
3001 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2")); 2991 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2"));
3002 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) }; 2992 base::string16 one_menu_item2[] = {ASCIIToUTF16(user2)};
3003 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1); 2993 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1);
3004 2994
3005 // Switch to the other user and make sure that only that browser window gets 2995 // Switch to the other user and make sure that only that browser window gets
3006 // shown. 2996 // shown.
3007 SwitchActiveUser(account_id2); 2997 SwitchActiveUser(account_id2);
3008 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2); 2998 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2);
3009 2999
3010 // Transferred browsers of other users should not show up in the list. 3000 // Transferred browsers of other users should not show up in the list.
3011 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( 3001 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(
3012 browser()->window()->GetNativeWindow(), account_id2); 3002 browser()->window()->GetNativeWindow(), account_id2);
3013 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2); 3003 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2);
3014 3004
3015 chrome::CloseTab(browser2.get()); 3005 chrome::CloseTab(browser2.get());
3016 } 3006 }
3017 3007
3018 // Check that V1 apps are correctly reflected in the launcher menu using the 3008 // Check that V1 apps are correctly reflected in the launcher menu using the
3019 // refocus logic. 3009 // refocus logic.
3020 // Note that the extension matching logic is tested by the extension system 3010 // Note that the extension matching logic is tested by the extension system
3021 // and does not need a separate test here. 3011 // and does not need a separate test here.
3022 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuGeneration) { 3012 TEST_F(ChromeLauncherControllerTest, V1AppMenuGeneration) {
3023 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 3013 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
3024 EXPECT_EQ(0, browser()->tab_strip_model()->count()); 3014 EXPECT_EQ(0, browser()->tab_strip_model()->count());
3025 3015
3026 InitLauncherControllerWithBrowser(); 3016 InitLauncherControllerWithBrowser();
3027 3017
3028 // The model should only contain the browser shortcut and app list items. 3018 // The model should only contain the browser shortcut and app list items.
3029 EXPECT_EQ(2, model_->item_count()); 3019 EXPECT_EQ(2, model_->item_count());
3030 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 3020 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
3031 3021
3032 // Installing |extension3_| adds it to the launcher. 3022 // Installing |extension3_| adds it to the launcher.
(...skipping 13 matching lines...) Expand all
3046 3036
3047 ash::ShelfItem item_gmail; 3037 ash::ShelfItem item_gmail;
3048 item_gmail.type = ash::TYPE_PINNED_APP; 3038 item_gmail.type = ash::TYPE_PINNED_APP;
3049 item_gmail.id = gmail_id; 3039 item_gmail.id = gmail_id;
3050 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3040 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3051 3041
3052 // Set the gmail URL to a new tab. 3042 // Set the gmail URL to a new tab.
3053 base::string16 title1 = ASCIIToUTF16("Test1"); 3043 base::string16 title1 = ASCIIToUTF16("Test1");
3054 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3044 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3055 3045
3056 base::string16 one_menu_item[] = { title1 }; 3046 base::string16 one_menu_item[] = {title1};
3057 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); 3047 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item);
3058 3048
3059 // Create one empty tab. 3049 // Create one empty tab.
3060 chrome::NewTab(browser()); 3050 chrome::NewTab(browser());
3061 base::string16 title2 = ASCIIToUTF16("Test2"); 3051 base::string16 title2 = ASCIIToUTF16("Test2");
3062 NavigateAndCommitActiveTabWithTitle( 3052 NavigateAndCommitActiveTabWithTitle(browser(), GURL("https://bla"), title2);
3063 browser(),
3064 GURL("https://bla"),
3065 title2);
3066 3053
3067 // and another one with another gmail instance. 3054 // and another one with another gmail instance.
3068 chrome::NewTab(browser()); 3055 chrome::NewTab(browser());
3069 base::string16 title3 = ASCIIToUTF16("Test3"); 3056 base::string16 title3 = ASCIIToUTF16("Test3");
3070 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title3); 3057 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title3);
3071 base::string16 two_menu_items[] = {title1, title3}; 3058 base::string16 two_menu_items[] = {title1, title3};
3072 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); 3059 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items);
3073 3060
3074 // Even though the item is in the V1 app list, it should also be in the 3061 // Even though the item is in the V1 app list, it should also be in the
3075 // browser list. 3062 // browser list.
3076 base::string16 browser_menu_item[] = {title3}; 3063 base::string16 browser_menu_item[] = {title3};
3077 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item); 3064 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item);
3078 3065
3079 // Test that closing of (all) the item(s) does work (and all menus get 3066 // Test that closing of (all) the item(s) does work (and all menus get
3080 // updated properly). 3067 // updated properly).
3081 launcher_controller_->Close(item_gmail.id); 3068 launcher_controller_->Close(item_gmail.id);
3082 3069
3083 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3070 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3084 base::string16 browser_menu_item2[] = { title2 }; 3071 base::string16 browser_menu_item2[] = {title2};
3085 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item2); 3072 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item2);
3086 } 3073 }
3087 3074
3088 // Check the multi profile case where only user related apps should show up. 3075 // Check the multi profile case where only user related apps should show up.
3089 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3076 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3090 V1AppMenuGenerationTwoUsers) { 3077 V1AppMenuGenerationTwoUsers) {
3091 // Create a browser item in the LauncherController. 3078 // Create a browser item in the LauncherController.
3092 InitLauncherController(); 3079 InitLauncherController();
3093 chrome::NewTab(browser()); 3080 chrome::NewTab(browser());
3094 3081
3095 // Installing |extension3_| adds it to the launcher. 3082 // Installing |extension3_| adds it to the launcher.
3096 ash::ShelfID gmail_id = model_->next_id(); 3083 ash::ShelfID gmail_id = model_->next_id();
3097 extension_service_->AddExtension(extension3_.get()); 3084 extension_service_->AddExtension(extension3_.get());
3098 EXPECT_EQ(3, model_->item_count()); 3085 EXPECT_EQ(3, model_->item_count());
3099 int gmail_index = model_->ItemIndexByID(gmail_id); 3086 int gmail_index = model_->ItemIndexByID(gmail_id);
3100 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); 3087 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type);
3101 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 3088 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
3102 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3089 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3103 3090
3104 // Check the menu content. 3091 // Check the menu content.
3105 ash::ShelfItem item_browser; 3092 ash::ShelfItem item_browser;
3106 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 3093 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
3107 item_browser.id = 3094 item_browser.id =
3108 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); 3095 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId);
3109 3096
3110 ash::ShelfItem item_gmail; 3097 ash::ShelfItem item_gmail;
3111 item_gmail.type = ash::TYPE_PINNED_APP; 3098 item_gmail.type = ash::TYPE_PINNED_APP;
3112 item_gmail.id = gmail_id; 3099 item_gmail.id = gmail_id;
3113 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3100 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3114 3101
3115 // Set the gmail URL to a new tab. 3102 // Set the gmail URL to a new tab.
3116 base::string16 title1 = ASCIIToUTF16("Test1"); 3103 base::string16 title1 = ASCIIToUTF16("Test1");
3117 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3104 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3118 3105
3119 base::string16 one_menu_item[] = { title1 }; 3106 base::string16 one_menu_item[] = {title1};
3120 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); 3107 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item);
3121 3108
3122 // Create a second profile and switch to that user. 3109 // Create a second profile and switch to that user.
3123 std::string user2 = "user2"; 3110 std::string user2 = "user2";
3124 TestingProfile* profile2 = CreateMultiUserProfile(user2); 3111 TestingProfile* profile2 = CreateMultiUserProfile(user2);
3125 const AccountId account_id2( 3112 const AccountId account_id2(
3126 multi_user_util::GetAccountIdFromProfile(profile2)); 3113 multi_user_util::GetAccountIdFromProfile(profile2));
3127 SwitchActiveUser(account_id2); 3114 SwitchActiveUser(account_id2);
3128 3115
3129 // No item should have content yet. 3116 // No item should have content yet.
3130 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); 3117 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr);
3131 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3118 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3132 3119
3133 // Transfer the browser of the first user - it should still not show up. 3120 // Transfer the browser of the first user - it should still not show up.
3134 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( 3121 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(
3135 browser()->window()->GetNativeWindow(), account_id2); 3122 browser()->window()->GetNativeWindow(), account_id2);
3136 3123
3137 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); 3124 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr);
3138 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3125 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3139 } 3126 }
3140 3127
3141 // Check that V2 applications are creating items properly in the launcher when 3128 // Check that V2 applications are creating items properly in the launcher when
3142 // instantiated by the current user. 3129 // instantiated by the current user.
3143 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3130 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3144 V2AppHandlingTwoUsers) { 3131 V2AppHandlingTwoUsers) {
3145 InitLauncherController(); 3132 InitLauncherController();
3146 // Create a profile for our second user (will be destroyed by the framework). 3133 // Create a profile for our second user (will be destroyed by the framework).
3147 TestingProfile* profile2 = CreateMultiUserProfile("user2"); 3134 TestingProfile* profile2 = CreateMultiUserProfile("user2");
3148 const AccountId account_id( 3135 const AccountId account_id(
3149 multi_user_util::GetAccountIdFromProfile(profile())); 3136 multi_user_util::GetAccountIdFromProfile(profile()));
3150 const AccountId account_id2( 3137 const AccountId account_id2(
3151 multi_user_util::GetAccountIdFromProfile(profile2)); 3138 multi_user_util::GetAccountIdFromProfile(profile2));
3152 // Check that there is a browser and a app launcher. 3139 // Check that there is a browser and a app launcher.
3153 EXPECT_EQ(2, model_->item_count()); 3140 EXPECT_EQ(2, model_->item_count());
3154 3141
3155 // Add a v2 app. 3142 // Add a v2 app.
3156 V2App v2_app(profile(), extension1_.get()); 3143 V2App v2_app(profile(), extension1_.get());
3157 EXPECT_EQ(3, model_->item_count()); 3144 EXPECT_EQ(3, model_->item_count());
3158 3145
3159 // After switching users the item should go away. 3146 // After switching users the item should go away.
3160 SwitchActiveUser(account_id2); 3147 SwitchActiveUser(account_id2);
3161 EXPECT_EQ(2, model_->item_count()); 3148 EXPECT_EQ(2, model_->item_count());
3162 3149
3163 // And it should come back when switching back. 3150 // And it should come back when switching back.
3164 SwitchActiveUser(account_id); 3151 SwitchActiveUser(account_id);
3165 EXPECT_EQ(3, model_->item_count()); 3152 EXPECT_EQ(3, model_->item_count());
3166 } 3153 }
3167 3154
3168 // Check that V2 applications are creating items properly in edge cases: 3155 // Check that V2 applications are creating items properly in edge cases:
3169 // a background user creates a V2 app, gets active and inactive again and then 3156 // a background user creates a V2 app, gets active and inactive again and then
3170 // deletes the app. 3157 // deletes the app.
3171 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3158 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3172 V2AppHandlingTwoUsersEdgeCases) { 3159 V2AppHandlingTwoUsersEdgeCases) {
3173 InitLauncherController(); 3160 InitLauncherController();
3174 // Create a profile for our second user (will be destroyed by the framework). 3161 // Create a profile for our second user (will be destroyed by the framework).
3175 TestingProfile* profile2 = CreateMultiUserProfile("user2"); 3162 TestingProfile* profile2 = CreateMultiUserProfile("user2");
3176 const AccountId account_id( 3163 const AccountId account_id(
3177 multi_user_util::GetAccountIdFromProfile(profile())); 3164 multi_user_util::GetAccountIdFromProfile(profile()));
3178 const AccountId account_id2( 3165 const AccountId account_id2(
3179 multi_user_util::GetAccountIdFromProfile(profile2)); 3166 multi_user_util::GetAccountIdFromProfile(profile2));
3180 // Check that there is a browser and a app launcher. 3167 // Check that there is a browser and a app launcher.
3181 EXPECT_EQ(2, model_->item_count()); 3168 EXPECT_EQ(2, model_->item_count());
(...skipping 22 matching lines...) Expand all
3204 EXPECT_EQ(2, model_->item_count()); 3191 EXPECT_EQ(2, model_->item_count());
3205 3192
3206 // Switching then back to the default user should not show the additional item 3193 // Switching then back to the default user should not show the additional item
3207 // anymore. 3194 // anymore.
3208 SwitchActiveUser(account_id); 3195 SwitchActiveUser(account_id);
3209 EXPECT_EQ(2, model_->item_count()); 3196 EXPECT_EQ(2, model_->item_count());
3210 } 3197 }
3211 3198
3212 // Check that V2 applications will be made visible on the target desktop if 3199 // Check that V2 applications will be made visible on the target desktop if
3213 // another window of the same type got previously teleported there. 3200 // another window of the same type got previously teleported there.
3214 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3201 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3215 V2AppFollowsTeleportedWindow) { 3202 V2AppFollowsTeleportedWindow) {
3216 InitLauncherController(); 3203 InitLauncherController();
3217 chrome::MultiUserWindowManager* manager = 3204 chrome::MultiUserWindowManager* manager =
3218 chrome::MultiUserWindowManager::GetInstance(); 3205 chrome::MultiUserWindowManager::GetInstance();
3219 3206
3220 // Create and add three users / profiles, and go to #1's desktop. 3207 // Create and add three users / profiles, and go to #1's desktop.
3221 TestingProfile* profile1 = CreateMultiUserProfile("user-1"); 3208 TestingProfile* profile1 = CreateMultiUserProfile("user-1");
3222 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); 3209 TestingProfile* profile2 = CreateMultiUserProfile("user-2");
3223 TestingProfile* profile3 = CreateMultiUserProfile("user-3"); 3210 TestingProfile* profile3 = CreateMultiUserProfile("user-3");
3224 const AccountId account_id1( 3211 const AccountId account_id1(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 SwitchActiveUser(account_id2); 3262 SwitchActiveUser(account_id2);
3276 v2_app_1.window()->Hide(); 3263 v2_app_1.window()->Hide();
3277 V2App v2_app_6(profile1, extension1_.get()); 3264 V2App v2_app_6(profile1, extension1_.get());
3278 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); 3265 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible());
3279 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); 3266 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible());
3280 EXPECT_TRUE(v2_app_6.window()->GetNativeWindow()->IsVisible()); 3267 EXPECT_TRUE(v2_app_6.window()->GetNativeWindow()->IsVisible());
3281 } 3268 }
3282 3269
3283 // Check that V2 applications hide correctly on the shelf when the app window 3270 // Check that V2 applications hide correctly on the shelf when the app window
3284 // is hidden. 3271 // is hidden.
3285 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3272 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3286 V2AppHiddenWindows) { 3273 V2AppHiddenWindows) {
3287 InitLauncherController(); 3274 InitLauncherController();
3288 3275
3289 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); 3276 TestingProfile* profile2 = CreateMultiUserProfile("user-2");
3290 const AccountId account_id( 3277 const AccountId account_id(
3291 multi_user_util::GetAccountIdFromProfile(profile())); 3278 multi_user_util::GetAccountIdFromProfile(profile()));
3292 const AccountId account_id2( 3279 const AccountId account_id2(
3293 multi_user_util::GetAccountIdFromProfile(profile2)); 3280 multi_user_util::GetAccountIdFromProfile(profile2));
3294 SwitchActiveUser(account_id); 3281 SwitchActiveUser(account_id);
3295 EXPECT_EQ(2, model_->item_count()); 3282 EXPECT_EQ(2, model_->item_count());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3347 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE); 3334 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE);
3348 EXPECT_EQ(3, model_->item_count()); 3335 EXPECT_EQ(3, model_->item_count());
3349 3336
3350 v2_app_1.window()->Hide(); 3337 v2_app_1.window()->Hide();
3351 v2_app_2.window()->Hide(); 3338 v2_app_2.window()->Hide();
3352 EXPECT_EQ(2, model_->item_count()); 3339 EXPECT_EQ(2, model_->item_count());
3353 } 3340 }
3354 } 3341 }
3355 3342
3356 // Checks that the generated menu list properly activates items. 3343 // Checks that the generated menu list properly activates items.
3357 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuExecution) { 3344 TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) {
3358 InitLauncherControllerWithBrowser(); 3345 InitLauncherControllerWithBrowser();
3359 3346
3360 // Add |extension3_| to the launcher and add two items. 3347 // Add |extension3_| to the launcher and add two items.
3361 GURL gmail = GURL("https://mail.google.com/mail/u"); 3348 GURL gmail = GURL("https://mail.google.com/mail/u");
3362 ash::ShelfID gmail_id = model_->next_id(); 3349 ash::ShelfID gmail_id = model_->next_id();
3363 extension_service_->AddExtension(extension3_.get()); 3350 extension_service_->AddExtension(extension3_.get());
3364 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3351 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3365 base::string16 title1 = ASCIIToUTF16("Test1"); 3352 base::string16 title1 = ASCIIToUTF16("Test1");
3366 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3353 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3367 chrome::NewTab(browser()); 3354 chrome::NewTab(browser());
(...skipping 27 matching lines...) Expand all
3395 ash::ShelfApplicationMenuModel menu( 3382 ash::ShelfApplicationMenuModel menu(
3396 base::string16(), 3383 base::string16(),
3397 launcher_controller_->GetAppMenuItemsForTesting(item_gmail), 3384 launcher_controller_->GetAppMenuItemsForTesting(item_gmail),
3398 item_delegate); 3385 item_delegate);
3399 menu.ActivatedAt(3); 3386 menu.ActivatedAt(3);
3400 } 3387 }
3401 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 3388 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
3402 } 3389 }
3403 3390
3404 // Checks that the generated menu list properly deletes items. 3391 // Checks that the generated menu list properly deletes items.
3405 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuDeletionExecution) { 3392 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) {
3406 InitLauncherControllerWithBrowser(); 3393 InitLauncherControllerWithBrowser();
3407 3394
3408 // Add |extension3_| to the launcher and add two items. 3395 // Add |extension3_| to the launcher and add two items.
3409 GURL gmail = GURL("https://mail.google.com/mail/u"); 3396 GURL gmail = GURL("https://mail.google.com/mail/u");
3410 ash::ShelfID gmail_id = model_->next_id(); 3397 ash::ShelfID gmail_id = model_->next_id();
3411 extension_service_->AddExtension(extension3_.get()); 3398 extension_service_->AddExtension(extension3_.get());
3412 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3399 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3413 base::string16 title1 = ASCIIToUTF16("Test1"); 3400 base::string16 title1 = ASCIIToUTF16("Test1");
3414 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3401 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3415 chrome::NewTab(browser()); 3402 chrome::NewTab(browser());
(...skipping 22 matching lines...) Expand all
3438 // Delete one tab through the menu item. 3425 // Delete one tab through the menu item.
3439 { 3426 {
3440 ash::MenuItemList items = 3427 ash::MenuItemList items =
3441 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); 3428 launcher_controller_->GetAppMenuItemsForTesting(item_gmail);
3442 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_SHIFT_DOWN); 3429 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_SHIFT_DOWN);
3443 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); 3430 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count());
3444 } 3431 }
3445 } 3432 }
3446 3433
3447 // Tests that panels create launcher items correctly 3434 // Tests that panels create launcher items correctly
3448 TEST_F(ChromeLauncherControllerImplTest, AppPanels) { 3435 TEST_F(ChromeLauncherControllerTest, AppPanels) {
3449 InitLauncherController(); 3436 InitLauncherController();
3450 model_observer_->clear_counts(); 3437 model_observer_->clear_counts();
3451 const std::string app_id = extension1_->id(); 3438 const std::string app_id = extension1_->id();
3452 3439
3453 // app_icon_loader is owned by ChromeLauncherControllerImpl. 3440 // app_icon_loader is owned by ChromeLauncherController.
3454 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); 3441 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl();
3455 app_icon_loader->AddSupportedApp(app_id); 3442 app_icon_loader->AddSupportedApp(app_id);
3456 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 3443 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
3457 3444
3458 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher. 3445 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher.
3459 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>( 3446 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>(
3460 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL); 3447 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL);
3461 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible()); 3448 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible());
3462 int panel_index = model_observer_->last_index(); 3449 int panel_index = model_observer_->last_index();
3463 EXPECT_EQ(1, model_observer_->added()); 3450 EXPECT_EQ(1, model_observer_->added());
(...skipping 18 matching lines...) Expand all
3482 EXPECT_EQ(1, model_observer_->added()); 3469 EXPECT_EQ(1, model_observer_->added());
3483 model_observer_->clear_counts(); 3470 model_observer_->clear_counts();
3484 3471
3485 app_panel1.reset(); 3472 app_panel1.reset();
3486 app_panel2.reset(); 3473 app_panel2.reset();
3487 EXPECT_EQ(2, model_observer_->removed()); 3474 EXPECT_EQ(2, model_observer_->removed());
3488 } 3475 }
3489 3476
3490 // Tests that the Gmail extension matches more than the app itself claims with 3477 // Tests that the Gmail extension matches more than the app itself claims with
3491 // the manifest file. 3478 // the manifest file.
3492 TEST_F(ChromeLauncherControllerImplTest, GmailMatching) { 3479 TEST_F(ChromeLauncherControllerTest, GmailMatching) {
3493 InitLauncherControllerWithBrowser(); 3480 InitLauncherControllerWithBrowser();
3494 3481
3495 // Create a Gmail browser tab. 3482 // Create a Gmail browser tab.
3496 chrome::NewTab(browser()); 3483 chrome::NewTab(browser());
3497 base::string16 title = ASCIIToUTF16("Test"); 3484 base::string16 title = ASCIIToUTF16("Test");
3498 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title); 3485 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title);
3499 content::WebContents* content = 3486 content::WebContents* content =
3500 browser()->tab_strip_model()->GetActiveWebContents(); 3487 browser()->tab_strip_model()->GetActiveWebContents();
3501 3488
3502 // Check that the launcher controller does not recognize the running app. 3489 // Check that the launcher controller does not recognize the running app.
(...skipping 12 matching lines...) Expand all
3515 3502
3516 // Check also that the app has detected that properly. 3503 // Check also that the app has detected that properly.
3517 ash::ShelfItem item_gmail; 3504 ash::ShelfItem item_gmail;
3518 item_gmail.type = ash::TYPE_PINNED_APP; 3505 item_gmail.type = ash::TYPE_PINNED_APP;
3519 item_gmail.id = gmail_id; 3506 item_gmail.id = gmail_id;
3520 EXPECT_EQ(1U, 3507 EXPECT_EQ(1U,
3521 launcher_controller_->GetAppMenuItemsForTesting(item_gmail).size()); 3508 launcher_controller_->GetAppMenuItemsForTesting(item_gmail).size());
3522 } 3509 }
3523 3510
3524 // Tests that the Gmail extension does not match the offline verison. 3511 // Tests that the Gmail extension does not match the offline verison.
3525 TEST_F(ChromeLauncherControllerImplTest, GmailOfflineMatching) { 3512 TEST_F(ChromeLauncherControllerTest, GmailOfflineMatching) {
3526 InitLauncherControllerWithBrowser(); 3513 InitLauncherControllerWithBrowser();
3527 3514
3528 // Create a Gmail browser tab. 3515 // Create a Gmail browser tab.
3529 chrome::NewTab(browser()); 3516 chrome::NewTab(browser());
3530 base::string16 title = ASCIIToUTF16("Test"); 3517 base::string16 title = ASCIIToUTF16("Test");
3531 NavigateAndCommitActiveTabWithTitle(browser(), 3518 NavigateAndCommitActiveTabWithTitle(browser(), GURL(offline_gmail_url),
3532 GURL(offline_gmail_url),
3533 title); 3519 title);
3534 content::WebContents* content = 3520 content::WebContents* content =
3535 browser()->tab_strip_model()->GetActiveWebContents(); 3521 browser()->tab_strip_model()->GetActiveWebContents();
3536 3522
3537 // Installing |extension3_| adds it to the launcher. 3523 // Installing |extension3_| adds it to the launcher.
3538 ash::ShelfID gmail_id = model_->next_id(); 3524 ash::ShelfID gmail_id = model_->next_id();
3539 extension_service_->AddExtension(extension3_.get()); 3525 extension_service_->AddExtension(extension3_.get());
3540 EXPECT_EQ(3, model_->item_count()); 3526 EXPECT_EQ(3, model_->item_count());
3541 int gmail_index = model_->ItemIndexByID(gmail_id); 3527 int gmail_index = model_->ItemIndexByID(gmail_id);
3542 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); 3528 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type);
3543 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 3529 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
3544 3530
3545 // The content should not be able to be handled by the app. 3531 // The content should not be able to be handled by the app.
3546 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); 3532 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
3547 } 3533 }
3548 3534
3549 // Verify that the launcher item positions are persisted and restored. 3535 // Verify that the launcher item positions are persisted and restored.
3550 TEST_F(ChromeLauncherControllerImplTest, PersistLauncherItemPositions) { 3536 TEST_F(ChromeLauncherControllerTest, PersistLauncherItemPositions) {
3551 InitLauncherController(); 3537 InitLauncherController();
3552 3538
3553 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper; 3539 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper;
3554 SetLauncherControllerHelper(helper); 3540 SetLauncherControllerHelper(helper);
3555 3541
3556 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); 3542 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type);
3557 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[1].type); 3543 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[1].type);
3558 3544
3559 TabStripModel* tab_strip_model = browser()->tab_strip_model(); 3545 TabStripModel* tab_strip_model = browser()->tab_strip_model();
3560 EXPECT_EQ(0, tab_strip_model->count()); 3546 EXPECT_EQ(0, tab_strip_model->count());
(...skipping 20 matching lines...) Expand all
3581 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 3567 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
3582 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); 3568 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type);
3583 3569
3584 RecreateLauncherController(); 3570 RecreateLauncherController();
3585 helper = new TestLauncherControllerHelper(profile()); 3571 helper = new TestLauncherControllerHelper(profile());
3586 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); 3572 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1");
3587 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); 3573 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2");
3588 SetLauncherControllerHelper(helper); 3574 SetLauncherControllerHelper(helper);
3589 launcher_controller_->Init(); 3575 launcher_controller_->Init();
3590 3576
3591 // Check ShelfItems are restored after resetting ChromeLauncherControllerImpl. 3577 // Check ShelfItems are restored after resetting ChromeLauncherController.
3592 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); 3578 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type);
3593 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[1].type); 3579 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[1].type);
3594 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 3580 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
3595 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); 3581 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type);
3596 } 3582 }
3597 3583
3598 // Verifies pinned apps are persisted and restored. 3584 // Verifies pinned apps are persisted and restored.
3599 TEST_F(ChromeLauncherControllerImplTest, PersistPinned) { 3585 TEST_F(ChromeLauncherControllerTest, PersistPinned) {
3600 InitLauncherControllerWithBrowser(); 3586 InitLauncherControllerWithBrowser();
3601 size_t initial_size = model_->items().size(); 3587 size_t initial_size = model_->items().size();
3602 3588
3603 TabStripModel* tab_strip_model = browser()->tab_strip_model(); 3589 TabStripModel* tab_strip_model = browser()->tab_strip_model();
3604 EXPECT_EQ(1, tab_strip_model->count()); 3590 EXPECT_EQ(1, tab_strip_model->count());
3605 3591
3606 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper; 3592 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper;
3607 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); 3593 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1");
3608 SetLauncherControllerHelper(helper); 3594 SetLauncherControllerHelper(helper);
3609 3595
3610 // app_icon_loader is owned by ChromeLauncherControllerImpl. 3596 // app_icon_loader is owned by ChromeLauncherController.
3611 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl; 3597 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl;
3612 app_icon_loader->AddSupportedApp("1"); 3598 app_icon_loader->AddSupportedApp("1");
3613 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 3599 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
3614 EXPECT_EQ(0, app_icon_loader->fetch_count()); 3600 EXPECT_EQ(0, app_icon_loader->fetch_count());
3615 3601
3616 launcher_controller_->PinAppWithID("1"); 3602 launcher_controller_->PinAppWithID("1");
3617 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1"); 3603 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1");
3618 int app_index = model_->ItemIndexByID(id); 3604 int app_index = model_->ItemIndexByID(id);
3619 EXPECT_EQ(1, app_icon_loader->fetch_count()); 3605 EXPECT_EQ(1, app_icon_loader->fetch_count());
3620 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); 3606 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type);
3621 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 3607 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
3622 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 3608 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
3623 EXPECT_EQ(initial_size + 1, model_->items().size()); 3609 EXPECT_EQ(initial_size + 1, model_->items().size());
3624 3610
3625 RecreateLauncherController(); 3611 RecreateLauncherController();
3626 helper = new TestLauncherControllerHelper(profile()); 3612 helper = new TestLauncherControllerHelper(profile());
3627 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); 3613 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1");
3628 SetLauncherControllerHelper(helper); 3614 SetLauncherControllerHelper(helper);
3629 // app_icon_loader is owned by ChromeLauncherControllerImpl. 3615 // app_icon_loader is owned by ChromeLauncherController.
3630 app_icon_loader = new TestAppIconLoaderImpl; 3616 app_icon_loader = new TestAppIconLoaderImpl;
3631 app_icon_loader->AddSupportedApp("1"); 3617 app_icon_loader->AddSupportedApp("1");
3632 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 3618 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
3633 launcher_controller_->Init(); 3619 launcher_controller_->Init();
3634 3620
3635 EXPECT_EQ(1, app_icon_loader->fetch_count()); 3621 EXPECT_EQ(1, app_icon_loader->fetch_count());
3636 ASSERT_EQ(initial_size + 1, model_->items().size()); 3622 ASSERT_EQ(initial_size + 1, model_->items().size());
3637 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 3623 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
3638 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 3624 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
3639 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); 3625 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type);
3640 3626
3641 launcher_controller_->UnpinAppWithID("1"); 3627 launcher_controller_->UnpinAppWithID("1");
3642 ASSERT_EQ(initial_size, model_->items().size()); 3628 ASSERT_EQ(initial_size, model_->items().size());
3643 } 3629 }
3644 3630
3645 TEST_F(ChromeLauncherControllerImplTest, MultipleAppIconLoaders) { 3631 TEST_F(ChromeLauncherControllerTest, MultipleAppIconLoaders) {
3646 InitLauncherControllerWithBrowser(); 3632 InitLauncherControllerWithBrowser();
3647 3633
3648 const std::string app_id1 = extension1_->id(); 3634 const std::string app_id1 = extension1_->id();
3649 const std::string app_id2 = extension2_->id(); 3635 const std::string app_id2 = extension2_->id();
3650 const std::string app_id3 = extension3_->id(); 3636 const std::string app_id3 = extension3_->id();
3651 // app_icon_loader1 and app_icon_loader2 are owned by 3637 // app_icon_loader1 and app_icon_loader2 are owned by
3652 // ChromeLauncherControllerImpl. 3638 // ChromeLauncherController.
3653 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); 3639 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl();
3654 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); 3640 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl();
3655 app_icon_loader1->AddSupportedApp(app_id1); 3641 app_icon_loader1->AddSupportedApp(app_id1);
3656 app_icon_loader2->AddSupportedApp(app_id2); 3642 app_icon_loader2->AddSupportedApp(app_id2);
3657 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), 3643 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1),
3658 std::unique_ptr<AppIconLoader>(app_icon_loader2)); 3644 std::unique_ptr<AppIconLoader>(app_icon_loader2));
3659 3645
3660 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( 3646 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem(
3661 base::MakeUnique<ExtensionAppWindowLauncherItemController>( 3647 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3662 ash::AppLaunchId(app_id3)), 3648 ash::AppLaunchId(app_id3)),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3696 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3682 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3697 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3683 EXPECT_EQ(1, app_icon_loader2->clear_count());
3698 3684
3699 launcher_controller_->CloseLauncherItem(shelfId3); 3685 launcher_controller_->CloseLauncherItem(shelfId3);
3700 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3686 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3701 EXPECT_EQ(1, app_icon_loader1->clear_count()); 3687 EXPECT_EQ(1, app_icon_loader1->clear_count());
3702 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3688 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3703 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3689 EXPECT_EQ(1, app_icon_loader2->clear_count());
3704 } 3690 }
3705 3691
3706 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) { 3692 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPinPolicy) {
3707 InitLauncherControllerWithBrowser(); 3693 InitLauncherControllerWithBrowser();
3708 arc::mojom::AppInfo appinfo = CreateAppInfo( 3694 arc::mojom::AppInfo appinfo = CreateAppInfo(
3709 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); 3695 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE);
3710 const std::string app_id = AddArcAppAndShortcut(appinfo); 3696 const std::string app_id = AddArcAppAndShortcut(appinfo);
3711 3697
3712 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app 3698 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app
3713 // package_name (not hash) specified as id. In this test we check that 3699 // package_name (not hash) specified as id. In this test we check that
3714 // by hash we can determine that appropriate package was set by policy. 3700 // by hash we can determine that appropriate package was set by policy.
3715 base::ListValue policy_value; 3701 base::ListValue policy_value;
3716 InsertPrefValue(&policy_value, 0, appinfo.package_name); 3702 InsertPrefValue(&policy_value, 0, appinfo.package_name);
3717 profile()->GetTestingPrefService()->SetManagedPref( 3703 profile()->GetTestingPrefService()->SetManagedPref(
3718 prefs::kPolicyPinnedLauncherApps, policy_value.CreateDeepCopy()); 3704 prefs::kPolicyPinnedLauncherApps, policy_value.CreateDeepCopy());
3719 3705
3720 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 3706 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
3721 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 3707 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
3722 GetPinnableForAppID(app_id, profile())); 3708 GetPinnableForAppID(app_id, profile()));
3723 } 3709 }
3724 3710
3725 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcManaged) { 3711 TEST_P(ChromeLauncherControllerWithArcTest, ArcManaged) {
3726 // TODO(victorhsieh): Implement opt-in and opt-out. 3712 // TODO(victorhsieh): Implement opt-in and opt-out.
3727 if (arc::ShouldArcAlwaysStart()) 3713 if (arc::ShouldArcAlwaysStart())
3728 return; 3714 return;
3729 3715
3730 extension_service_->AddExtension(arc_support_host_.get()); 3716 extension_service_->AddExtension(arc_support_host_.get());
3731 // Test enables ARC, so turn it off for initial values. 3717 // Test enables ARC, so turn it off for initial values.
3732 EnablePlayStore(false); 3718 EnablePlayStore(false);
3733 3719
3734 InitLauncherController(); 3720 InitLauncherController();
3735 3721
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3777 "AppList, Chrome"); 3763 "AppList, Chrome");
3778 3764
3779 // Even if re-enable it again, Play Store pin does not appear automatically. 3765 // Even if re-enable it again, Play Store pin does not appear automatically.
3780 EnablePlayStore(true); 3766 EnablePlayStore(true);
3781 ValidateArcState(true, false, 3767 ValidateArcState(true, false,
3782 arc::ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, 3768 arc::ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE,
3783 "AppList, Chrome"); 3769 "AppList, Chrome");
3784 } 3770 }
3785 3771
3786 // Test the application menu of a shelf item with multiple ARC windows. 3772 // Test the application menu of a shelf item with multiple ARC windows.
3787 TEST_P(ChromeLauncherControllerImplWithArcTest, ShelfItemWithMultipleWindows) { 3773 TEST_P(ChromeLauncherControllerWithArcTest, ShelfItemWithMultipleWindows) {
3788 InitLauncherControllerWithBrowser(); 3774 InitLauncherControllerWithBrowser();
3789 3775
3790 arc::mojom::AppInfo appinfo = 3776 arc::mojom::AppInfo appinfo =
3791 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE); 3777 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE);
3792 AddArcAppAndShortcut(appinfo); 3778 AddArcAppAndShortcut(appinfo);
3793 3779
3794 // Widgets will be deleted by the system. 3780 // Widgets will be deleted by the system.
3795 NotifyOnTaskCreated(appinfo, 1 /* task_id */); 3781 NotifyOnTaskCreated(appinfo, 1 /* task_id */);
3796 views::Widget* window1 = CreateArcWindow("org.chromium.arc.1"); 3782 views::Widget* window1 = CreateArcWindow("org.chromium.arc.1");
3797 ASSERT_TRUE(window1); 3783 ASSERT_TRUE(window1);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3838 3824
3839 // Execute command to activate second window. 3825 // Execute command to activate second window.
3840 item_delegate->ExecuteCommand(items[0]->command_id, 0); 3826 item_delegate->ExecuteCommand(items[0]->command_id, 0);
3841 EXPECT_FALSE(window1->IsActive()); 3827 EXPECT_FALSE(window1->IsActive());
3842 EXPECT_TRUE(window2->IsActive()); 3828 EXPECT_TRUE(window2->IsActive());
3843 } 3829 }
3844 3830
3845 namespace { 3831 namespace {
3846 3832
3847 class ChromeLauncherControllerOrientationTest 3833 class ChromeLauncherControllerOrientationTest
3848 : public ChromeLauncherControllerImplWithArcTest { 3834 : public ChromeLauncherControllerWithArcTest {
3849 public: 3835 public:
3850 ChromeLauncherControllerOrientationTest() {} 3836 ChromeLauncherControllerOrientationTest() {}
3851 ~ChromeLauncherControllerOrientationTest() override {} 3837 ~ChromeLauncherControllerOrientationTest() override {}
3852 3838
3853 protected: 3839 protected:
3854 void InitApps() { 3840 void InitApps() {
3855 appinfo_none_ = 3841 appinfo_none_ =
3856 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE); 3842 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE);
3857 appinfo_landscape_ = 3843 appinfo_landscape_ =
3858 CreateAppInfo("Landscape", "Landscape", "com.example.app", 3844 CreateAppInfo("Landscape", "Landscape", "com.example.app",
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3916 3902
3917 private: 3903 private:
3918 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); 3904 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest);
3919 }; 3905 };
3920 3906
3921 INSTANTIATE_TEST_CASE_P(, 3907 INSTANTIATE_TEST_CASE_P(,
3922 ChromeLauncherControllerOrientationTest, 3908 ChromeLauncherControllerOrientationTest,
3923 ::testing::Bool()); 3909 ::testing::Bool());
3924 3910
3925 class ChromeLauncherControllerArcDefaultAppsTest 3911 class ChromeLauncherControllerArcDefaultAppsTest
3926 : public ChromeLauncherControllerImplTest, 3912 : public ChromeLauncherControllerTest,
3927 public ::testing::WithParamInterface<bool> { 3913 public ::testing::WithParamInterface<bool> {
3928 public: 3914 public:
3929 ChromeLauncherControllerArcDefaultAppsTest() {} 3915 ChromeLauncherControllerArcDefaultAppsTest() {}
3930 ~ChromeLauncherControllerArcDefaultAppsTest() override {} 3916 ~ChromeLauncherControllerArcDefaultAppsTest() override {}
3931 3917
3932 protected: 3918 protected:
3933 void SetUp() override { 3919 void SetUp() override {
3934 if (GetParam()) 3920 if (GetParam())
3935 arc::SetArcAlwaysStartForTesting(); 3921 arc::SetArcAlwaysStartForTesting();
3936 ArcDefaultAppList::UseTestAppsDirectory(); 3922 ArcDefaultAppList::UseTestAppsDirectory();
3937 ChromeLauncherControllerImplTest::SetUp(); 3923 ChromeLauncherControllerTest::SetUp();
3938 } 3924 }
3939 3925
3940 private: 3926 private:
3941 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); 3927 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest);
3942 }; 3928 };
3943 3929
3944 INSTANTIATE_TEST_CASE_P(, 3930 INSTANTIATE_TEST_CASE_P(,
3945 ChromeLauncherControllerArcDefaultAppsTest, 3931 ChromeLauncherControllerArcDefaultAppsTest,
3946 ::testing::Bool()); 3932 ::testing::Bool());
3947 3933
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
4159 launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId)); 4145 launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId));
4160 EXPECT_TRUE(item_delegate); 4146 EXPECT_TRUE(item_delegate);
4161 SelectItem(item_delegate); 4147 SelectItem(item_delegate);
4162 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); 4148 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId));
4163 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp( 4149 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(
4164 arc::kPlayStoreAppId)); 4150 arc::kPlayStoreAppId));
4165 } 4151 }
4166 4152
4167 // Checks the case when several app items have the same ordinal position (which 4153 // Checks the case when several app items have the same ordinal position (which
4168 // is valid case). 4154 // is valid case).
4169 TEST_F(ChromeLauncherControllerImplTest, CheckPositionConflict) { 4155 TEST_F(ChromeLauncherControllerTest, CheckPositionConflict) {
4170 InitLauncherController(); 4156 InitLauncherController();
4171 4157
4172 extension_service_->AddExtension(extension1_.get()); 4158 extension_service_->AddExtension(extension1_.get());
4173 extension_service_->AddExtension(extension2_.get()); 4159 extension_service_->AddExtension(extension2_.get());
4174 extension_service_->AddExtension(extension3_.get()); 4160 extension_service_->AddExtension(extension3_.get());
4175 4161
4176 syncer::SyncChangeList sync_list; 4162 syncer::SyncChangeList sync_list;
4177 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); 4163 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId);
4178 InsertAddPinChange(&sync_list, 1, extension1_->id()); 4164 InsertAddPinChange(&sync_list, 1, extension1_->id());
4179 InsertAddPinChange(&sync_list, 1, extension2_->id()); 4165 InsertAddPinChange(&sync_list, 1, extension2_->id());
(...skipping 29 matching lines...) Expand all
4209 EXPECT_TRUE( 4195 EXPECT_TRUE(
4210 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); 4196 position_1.Equals(app_service_->GetPinPosition(extension1_->id())));
4211 EXPECT_TRUE( 4197 EXPECT_TRUE(
4212 position_2.Equals(app_service_->GetPinPosition(extension2_->id()))); 4198 position_2.Equals(app_service_->GetPinPosition(extension2_->id())));
4213 EXPECT_TRUE( 4199 EXPECT_TRUE(
4214 position_3.Equals(app_service_->GetPinPosition(extension3_->id()))); 4200 position_3.Equals(app_service_->GetPinPosition(extension3_->id())));
4215 } 4201 }
4216 4202
4217 // Test the case when sync app is turned off and we need to use local copy to 4203 // Test the case when sync app is turned off and we need to use local copy to
4218 // support user's pins. 4204 // support user's pins.
4219 TEST_F(ChromeLauncherControllerImplTest, SyncOffLocalUpdate) { 4205 TEST_F(ChromeLauncherControllerTest, SyncOffLocalUpdate) {
4220 InitLauncherController(); 4206 InitLauncherController();
4221 4207
4222 extension_service_->AddExtension(extension1_.get()); 4208 extension_service_->AddExtension(extension1_.get());
4223 extension_service_->AddExtension(extension2_.get()); 4209 extension_service_->AddExtension(extension2_.get());
4224 4210
4225 syncer::SyncChangeList sync_list; 4211 syncer::SyncChangeList sync_list;
4226 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); 4212 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId);
4227 InsertAddPinChange(&sync_list, 1, extension1_->id()); 4213 InsertAddPinChange(&sync_list, 1, extension1_->id());
4228 InsertAddPinChange(&sync_list, 1, extension2_->id()); 4214 InsertAddPinChange(&sync_list, 1, extension2_->id());
4229 SendPinChanges(sync_list, true); 4215 SendPinChanges(sync_list, true);
(...skipping 10 matching lines...) Expand all
4240 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4226 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4241 launcher_controller_->UnpinAppWithID(extension2_->id()); 4227 launcher_controller_->UnpinAppWithID(extension2_->id());
4242 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 4228 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
4243 4229
4244 // Resume syncing and sync information overrides local copy. 4230 // Resume syncing and sync information overrides local copy.
4245 StartAppSyncService(copy_sync_list); 4231 StartAppSyncService(copy_sync_list);
4246 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4232 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4247 } 4233 }
4248 4234
4249 // Tests that shelf profile preferences are loaded on login. 4235 // Tests that shelf profile preferences are loaded on login.
4250 TEST_F(ChromeLauncherControllerImplTest, PrefsLoadedOnLogin) { 4236 TEST_F(ChromeLauncherControllerTest, PrefsLoadedOnLogin) {
4251 PrefService* prefs = profile()->GetTestingPrefService(); 4237 PrefService* prefs = profile()->GetTestingPrefService();
4252 prefs->SetString(prefs::kShelfAlignmentLocal, "Left"); 4238 prefs->SetString(prefs::kShelfAlignmentLocal, "Left");
4253 prefs->SetString(prefs::kShelfAlignment, "Left"); 4239 prefs->SetString(prefs::kShelfAlignment, "Left");
4254 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, "Always"); 4240 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, "Always");
4255 prefs->SetString(prefs::kShelfAutoHideBehavior, "Always"); 4241 prefs->SetString(prefs::kShelfAutoHideBehavior, "Always");
4256 4242
4257 TestChromeLauncherControllerImpl* test_launcher_controller = 4243 TestChromeLauncherController* test_launcher_controller =
4258 shell_delegate_->CreateTestLauncherController(profile()); 4244 shell_delegate_->CreateTestLauncherController(profile());
4259 4245
4260 // Simulate login for the test controller. 4246 // Simulate login for the test controller.
4261 test_launcher_controller->ReleaseProfile(); 4247 test_launcher_controller->ReleaseProfile();
4262 test_launcher_controller->AttachProfile(profile()); 4248 test_launcher_controller->AttachProfile(profile());
4263 base::RunLoop().RunUntilIdle(); 4249 base::RunLoop().RunUntilIdle();
4264 4250
4265 TestShelfController* shelf_controller = 4251 TestShelfController* shelf_controller =
4266 test_launcher_controller->test_shelf_controller(); 4252 test_launcher_controller->test_shelf_controller();
4267 ASSERT_TRUE(shelf_controller); 4253 ASSERT_TRUE(shelf_controller);
4268 EXPECT_EQ(ash::SHELF_ALIGNMENT_LEFT, shelf_controller->alignment()); 4254 EXPECT_EQ(ash::SHELF_ALIGNMENT_LEFT, shelf_controller->alignment());
4269 EXPECT_EQ(1u, shelf_controller->alignment_change_count()); 4255 EXPECT_EQ(1u, shelf_controller->alignment_change_count());
4270 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4256 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4271 shelf_controller->auto_hide()); 4257 shelf_controller->auto_hide());
4272 EXPECT_EQ(1u, shelf_controller->auto_hide_change_count()); 4258 EXPECT_EQ(1u, shelf_controller->auto_hide_change_count());
4273 } 4259 }
4274 4260
4275 // Tests that the shelf controller's changes are not wastefully echoed back. 4261 // Tests that the shelf controller's changes are not wastefully echoed back.
4276 TEST_F(ChromeLauncherControllerImplTest, DoNotEchoShelfControllerChanges) { 4262 TEST_F(ChromeLauncherControllerTest, DoNotEchoShelfControllerChanges) {
4277 TestChromeLauncherControllerImpl* test_launcher_controller = 4263 TestChromeLauncherController* test_launcher_controller =
4278 shell_delegate_->CreateTestLauncherController(profile()); 4264 shell_delegate_->CreateTestLauncherController(profile());
4279 4265
4280 // Simulate login for the test controller. 4266 // Simulate login for the test controller.
4281 test_launcher_controller->ReleaseProfile(); 4267 test_launcher_controller->ReleaseProfile();
4282 test_launcher_controller->AttachProfile(profile()); 4268 test_launcher_controller->AttachProfile(profile());
4283 base::RunLoop().RunUntilIdle(); 4269 base::RunLoop().RunUntilIdle();
4284 4270
4285 TestShelfController* shelf_controller = 4271 TestShelfController* shelf_controller =
4286 test_launcher_controller->test_shelf_controller(); 4272 test_launcher_controller->test_shelf_controller();
4287 ASSERT_TRUE(shelf_controller); 4273 ASSERT_TRUE(shelf_controller);
(...skipping 18 matching lines...) Expand all
4306 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4292 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4307 shelf_controller->auto_hide()); 4293 shelf_controller->auto_hide());
4308 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4294 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4309 4295
4310 PrefService* prefs = profile()->GetTestingPrefService(); 4296 PrefService* prefs = profile()->GetTestingPrefService();
4311 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4297 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4312 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4298 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4313 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4299 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4314 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4300 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4315 } 4301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698