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

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: Cleanup 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, / / NOLINT(whitespace/line_length)
James Cook 2017/04/26 22:17:13 might not need the NOLINT anymore
msw 2017/04/26 23:20:15 Done.
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 /*
1485 * Test ChromeLauncherControllerImpl correctly merges policy pinned apps 1480 * Test ChromeLauncherController correctly merges policy pinned apps
James Cook 2017/04/26 22:17:13 nit: fix wrong comment style while you're here
msw 2017/04/26 23:20:15 Done.
1486 * and user pinned apps 1481 * and user pinned apps
1487 */ 1482 */
1488 TEST_F(ChromeLauncherControllerImplTest, MergePolicyAndUserPrefPinnedApps) { 1483 TEST_F(ChromeLauncherControllerTest, MergePolicyAndUserPrefPinnedApps) {
1489 InitLauncherController(); 1484 InitLauncherController();
1490 1485
1491 extension_service_->AddExtension(extension1_.get()); 1486 extension_service_->AddExtension(extension1_.get());
1492 extension_service_->AddExtension(extension3_.get()); 1487 extension_service_->AddExtension(extension3_.get());
1493 extension_service_->AddExtension(extension4_.get()); 1488 extension_service_->AddExtension(extension4_.get());
1494 extension_service_->AddExtension(extension5_.get()); 1489 extension_service_->AddExtension(extension5_.get());
1495 // extension 1, 3 are pinned by user 1490 // extension 1, 3 are pinned by user
1496 syncer::SyncChangeList sync_list; 1491 syncer::SyncChangeList sync_list;
1497 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1492 InsertAddPinChange(&sync_list, 0, extension1_->id());
1498 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId); 1493 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId);
(...skipping 26 matching lines...) Expand all
1525 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 1520 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
1526 GetPinnableForAppID(extension4_->id(), profile())); 1521 GetPinnableForAppID(extension4_->id(), profile()));
1527 1522
1528 // Check the order of shelf pinned apps 1523 // Check the order of shelf pinned apps
1529 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus()); 1524 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus());
1530 } 1525 }
1531 1526
1532 // Check that the restauration of launcher items is happening in the same order 1527 // 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 1528 // as the user has pinned them (on another system) when they are synced reverse
1534 // order. 1529 // order.
1535 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsReverseOrder) { 1530 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsReverseOrder) {
1536 InitLauncherController(); 1531 InitLauncherController();
1537 1532
1538 syncer::SyncChangeList sync_list; 1533 syncer::SyncChangeList sync_list;
1539 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1534 InsertAddPinChange(&sync_list, 0, extension1_->id());
1540 InsertAddPinChange(&sync_list, 1, extension2_->id()); 1535 InsertAddPinChange(&sync_list, 1, extension2_->id());
1541 InsertAddPinChange(&sync_list, 2, extension3_->id()); 1536 InsertAddPinChange(&sync_list, 2, extension3_->id());
1542 SendPinChanges(sync_list, true); 1537 SendPinChanges(sync_list, true);
1543 1538
1544 // The model should only contain the browser shortcut and app list items. 1539 // The model should only contain the browser shortcut and app list items.
1545 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1540 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
(...skipping 17 matching lines...) Expand all
1563 1558
1564 // Installing |extension1_| should add it to the launcher - behind the 1559 // Installing |extension1_| should add it to the launcher - behind the
1565 // chrome icon, but in first location. 1560 // chrome icon, but in first location.
1566 extension_service_->AddExtension(extension1_.get()); 1561 extension_service_->AddExtension(extension1_.get());
1567 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus()); 1562 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus());
1568 } 1563 }
1569 1564
1570 // Check that the restauration of launcher items is happening in the same order 1565 // 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 1566 // as the user has pinned them (on another system) when they are synced random
1572 // order. 1567 // order.
1573 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsRandomOrder) { 1568 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrder) {
1574 InitLauncherController(); 1569 InitLauncherController();
1575 1570
1576 syncer::SyncChangeList sync_list; 1571 syncer::SyncChangeList sync_list;
1577 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1572 InsertAddPinChange(&sync_list, 0, extension1_->id());
1578 InsertAddPinChange(&sync_list, 1, extension2_->id()); 1573 InsertAddPinChange(&sync_list, 1, extension2_->id());
1579 InsertAddPinChange(&sync_list, 2, extension3_->id()); 1574 InsertAddPinChange(&sync_list, 2, extension3_->id());
1580 SendPinChanges(sync_list, true); 1575 SendPinChanges(sync_list, true);
1581 1576
1582 // The model should only contain the browser shortcut and app list items. 1577 // The model should only contain the browser shortcut and app list items.
1583 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1578 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
(...skipping 16 matching lines...) Expand all
1600 1595
1601 // Installing |extension3_| should add it to the launcher - behind the 1596 // Installing |extension3_| should add it to the launcher - behind the
1602 // chrome icon, but in first location. 1597 // chrome icon, but in first location.
1603 extension_service_->AddExtension(extension3_.get()); 1598 extension_service_->AddExtension(extension3_.get());
1604 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus()); 1599 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus());
1605 } 1600 }
1606 1601
1607 // Check that the restauration of launcher items is happening in the same order 1602 // 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 1603 // as the user has pinned / moved them (on another system) when they are synced
1609 // random order - including the chrome icon. 1604 // random order - including the chrome icon.
1610 TEST_F(ChromeLauncherControllerImplTest, 1605 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrderChromeMoved) {
1611 RestoreDefaultAppsRandomOrderChromeMoved) {
1612 InitLauncherController(); 1606 InitLauncherController();
1613 1607
1614 syncer::SyncChangeList sync_list; 1608 syncer::SyncChangeList sync_list;
1615 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1609 InsertAddPinChange(&sync_list, 0, extension1_->id());
1616 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId); 1610 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId);
1617 InsertAddPinChange(&sync_list, 2, extension2_->id()); 1611 InsertAddPinChange(&sync_list, 2, extension2_->id());
1618 InsertAddPinChange(&sync_list, 3, extension3_->id()); 1612 InsertAddPinChange(&sync_list, 3, extension3_->id());
1619 SendPinChanges(sync_list, true); 1613 SendPinChanges(sync_list, true);
1620 1614
1621 // The model should only contain the browser shortcut and app list items. 1615 // 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())); 1632 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1639 EXPECT_EQ("AppList, App1, Chrome, App2", GetPinnedAppStatus()); 1633 EXPECT_EQ("AppList, App1, Chrome, App2", GetPinnedAppStatus());
1640 1634
1641 // Installing |extension3_| should add it to the launcher - behind the 1635 // Installing |extension3_| should add it to the launcher - behind the
1642 // chrome icon, but in first location. 1636 // chrome icon, but in first location.
1643 extension_service_->AddExtension(extension3_.get()); 1637 extension_service_->AddExtension(extension3_.get());
1644 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus()); 1638 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus());
1645 } 1639 }
1646 1640
1647 // Check that syncing to a different state does the correct thing. 1641 // Check that syncing to a different state does the correct thing.
1648 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsResyncOrder) { 1642 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsResyncOrder) {
1649 InitLauncherController(); 1643 InitLauncherController();
1650 1644
1651 syncer::SyncChangeList sync_list0; 1645 syncer::SyncChangeList sync_list0;
1652 InsertAddPinChange(&sync_list0, 0, extension1_->id()); 1646 InsertAddPinChange(&sync_list0, 0, extension1_->id());
1653 InsertAddPinChange(&sync_list0, 1, extension2_->id()); 1647 InsertAddPinChange(&sync_list0, 1, extension2_->id());
1654 InsertAddPinChange(&sync_list0, 2, extension3_->id()); 1648 InsertAddPinChange(&sync_list0, 2, extension3_->id());
1655 SendPinChanges(sync_list0, true); 1649 SendPinChanges(sync_list0, true);
1656 1650
1657 // The shelf layout has always one static item at the beginning (App List). 1651 // The shelf layout has always one static item at the beginning (App List).
1658 extension_service_->AddExtension(extension2_.get()); 1652 extension_service_->AddExtension(extension2_.get());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 UnloadedExtensionInfo::REASON_UNINSTALL); 1690 UnloadedExtensionInfo::REASON_UNINSTALL);
1697 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1691 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1698 1692
1699 // Check that an update of an extension does not crash the system. 1693 // Check that an update of an extension does not crash the system.
1700 extension_service_->UnloadExtension(extension3_->id(), 1694 extension_service_->UnloadExtension(extension3_->id(),
1701 UnloadedExtensionInfo::REASON_UPDATE); 1695 UnloadedExtensionInfo::REASON_UPDATE);
1702 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1696 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1703 } 1697 }
1704 1698
1705 // Test the V1 app interaction flow: run it, activate it, close it. 1699 // Test the V1 app interaction flow: run it, activate it, close it.
1706 TEST_F(ChromeLauncherControllerImplTest, V1AppRunActivateClose) { 1700 TEST_F(ChromeLauncherControllerTest, V1AppRunActivateClose) {
1707 InitLauncherController(); 1701 InitLauncherController();
1708 // The model should only contain the browser shortcut and app list items. 1702 // The model should only contain the browser shortcut and app list items.
1709 EXPECT_EQ(2, model_->item_count()); 1703 EXPECT_EQ(2, model_->item_count());
1710 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1704 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1711 EXPECT_EQ(ash::kInvalidShelfID, 1705 EXPECT_EQ(ash::kInvalidShelfID,
1712 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1706 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1713 1707
1714 // Reporting that the app is running should create a new shelf item. 1708 // Reporting that the app is running should create a new shelf item.
1715 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1709 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1716 EXPECT_EQ(3, model_->item_count()); 1710 EXPECT_EQ(3, model_->item_count());
(...skipping 14 matching lines...) Expand all
1731 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1725 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1732 EXPECT_EQ(ash::kInvalidShelfID, 1726 EXPECT_EQ(ash::kInvalidShelfID,
1733 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1727 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1734 1728
1735 // Reporting that the app is closed again should have no effect. 1729 // Reporting that the app is closed again should have no effect.
1736 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); 1730 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1737 EXPECT_EQ(2, model_->item_count()); 1731 EXPECT_EQ(2, model_->item_count());
1738 } 1732 }
1739 1733
1740 // Test the V1 app interaction flow: pin it, run it, close it, unpin it. 1734 // Test the V1 app interaction flow: pin it, run it, close it, unpin it.
1741 TEST_F(ChromeLauncherControllerImplTest, V1AppPinRunCloseUnpin) { 1735 TEST_F(ChromeLauncherControllerTest, V1AppPinRunCloseUnpin) {
1742 InitLauncherController(); 1736 InitLauncherController();
1743 // The model should only contain the browser shortcut and app list items. 1737 // The model should only contain the browser shortcut and app list items.
1744 EXPECT_EQ(2, model_->item_count()); 1738 EXPECT_EQ(2, model_->item_count());
1745 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1739 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1746 EXPECT_EQ(ash::kInvalidShelfID, 1740 EXPECT_EQ(ash::kInvalidShelfID,
1747 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1741 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1748 1742
1749 // Pinning the app should create a new shelf item. 1743 // Pinning the app should create a new shelf item.
1750 launcher_controller_->PinAppWithID(extension1_->id()); 1744 launcher_controller_->PinAppWithID(extension1_->id());
1751 EXPECT_EQ(3, model_->item_count()); 1745 EXPECT_EQ(3, model_->item_count());
(...skipping 23 matching lines...) Expand all
1775 1769
1776 // Unpinning the app should remove its shelf item. 1770 // Unpinning the app should remove its shelf item.
1777 launcher_controller_->UnpinAppWithID(extension1_->id()); 1771 launcher_controller_->UnpinAppWithID(extension1_->id());
1778 EXPECT_EQ(2, model_->item_count()); 1772 EXPECT_EQ(2, model_->item_count());
1779 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1773 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1780 EXPECT_EQ(ash::kInvalidShelfID, 1774 EXPECT_EQ(ash::kInvalidShelfID,
1781 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1775 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1782 } 1776 }
1783 1777
1784 // Test the V1 app interaction flow: run it, pin it, close it, unpin it. 1778 // Test the V1 app interaction flow: run it, pin it, close it, unpin it.
1785 TEST_F(ChromeLauncherControllerImplTest, V1AppRunPinCloseUnpin) { 1779 TEST_F(ChromeLauncherControllerTest, V1AppRunPinCloseUnpin) {
1786 InitLauncherController(); 1780 InitLauncherController();
1787 // The model should only contain the browser shortcut and app list items. 1781 // The model should only contain the browser shortcut and app list items.
1788 EXPECT_EQ(2, model_->item_count()); 1782 EXPECT_EQ(2, model_->item_count());
1789 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1783 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1790 EXPECT_EQ(ash::kInvalidShelfID, 1784 EXPECT_EQ(ash::kInvalidShelfID,
1791 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1785 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1792 1786
1793 // Reporting that the app is running should create a new shelf item. 1787 // Reporting that the app is running should create a new shelf item.
1794 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1788 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1795 EXPECT_EQ(3, model_->item_count()); 1789 EXPECT_EQ(3, model_->item_count());
(...skipping 23 matching lines...) Expand all
1819 1813
1820 // Unpinning the app should remove its shelf item. 1814 // Unpinning the app should remove its shelf item.
1821 launcher_controller_->UnpinAppWithID(extension1_->id()); 1815 launcher_controller_->UnpinAppWithID(extension1_->id());
1822 EXPECT_EQ(2, model_->item_count()); 1816 EXPECT_EQ(2, model_->item_count());
1823 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1817 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1824 EXPECT_EQ(ash::kInvalidShelfID, 1818 EXPECT_EQ(ash::kInvalidShelfID,
1825 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1819 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1826 } 1820 }
1827 1821
1828 // Test the V1 app interaction flow: pin it, run it, unpin it, close it. 1822 // Test the V1 app interaction flow: pin it, run it, unpin it, close it.
1829 TEST_F(ChromeLauncherControllerImplTest, V1AppPinRunUnpinClose) { 1823 TEST_F(ChromeLauncherControllerTest, V1AppPinRunUnpinClose) {
1830 InitLauncherController(); 1824 InitLauncherController();
1831 // The model should only contain the browser shortcut and app list items. 1825 // The model should only contain the browser shortcut and app list items.
1832 EXPECT_EQ(2, model_->item_count()); 1826 EXPECT_EQ(2, model_->item_count());
1833 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1827 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1834 EXPECT_EQ(ash::kInvalidShelfID, 1828 EXPECT_EQ(ash::kInvalidShelfID,
1835 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1829 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1836 1830
1837 // Pinning the app should create a new shelf item. 1831 // Pinning the app should create a new shelf item.
1838 launcher_controller_->PinAppWithID(extension1_->id()); 1832 launcher_controller_->PinAppWithID(extension1_->id());
1839 EXPECT_EQ(3, model_->item_count()); 1833 EXPECT_EQ(3, model_->item_count());
(...skipping 23 matching lines...) Expand all
1863 1857
1864 // Reporting that the app is closed should remove its shelf item. 1858 // Reporting that the app is closed should remove its shelf item.
1865 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); 1859 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1866 EXPECT_EQ(2, model_->item_count()); 1860 EXPECT_EQ(2, model_->item_count());
1867 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1861 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1868 EXPECT_EQ(ash::kInvalidShelfID, 1862 EXPECT_EQ(ash::kInvalidShelfID,
1869 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1863 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1870 } 1864 }
1871 1865
1872 // Ensure unpinned V1 app ordering is properly restored after user changes. 1866 // Ensure unpinned V1 app ordering is properly restored after user changes.
1873 TEST_F(ChromeLauncherControllerImplTest, CheckRunningV1AppOrder) { 1867 TEST_F(ChromeLauncherControllerTest, CheckRunningV1AppOrder) {
1874 InitLauncherController(); 1868 InitLauncherController();
1875 // The model should only contain the browser shortcut and app list items. 1869 // The model should only contain the browser shortcut and app list items.
1876 EXPECT_EQ(2, model_->item_count()); 1870 EXPECT_EQ(2, model_->item_count());
1877 1871
1878 // Add a few running applications. 1872 // Add a few running applications.
1879 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1873 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1880 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_RUNNING); 1874 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_RUNNING);
1881 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_RUNNING); 1875 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_RUNNING);
1882 EXPECT_EQ(5, model_->item_count()); 1876 EXPECT_EQ(5, model_->item_count());
1883 // Note that this not only checks the order of applications but also the 1877 // Note that this not only checks the order of applications but also the
(...skipping 28 matching lines...) Expand all
1912 1906
1913 // Check that removing more items does not crash and changes nothing. 1907 // Check that removing more items does not crash and changes nothing.
1914 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_CLOSED); 1908 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_CLOSED);
1915 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1909 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1916 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); 1910 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus());
1917 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_CLOSED); 1911 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_CLOSED);
1918 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1912 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1919 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1913 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1920 } 1914 }
1921 1915
1922 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { 1916 TEST_P(ChromeLauncherControllerWithArcTest, ArcDeferredLaunch) {
1923 InitLauncherController(); 1917 InitLauncherController();
1924 1918
1925 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; 1919 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0];
1926 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; 1920 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1];
1927 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; 1921 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2];
1928 const arc::mojom::ShortcutInfo& shortcut = arc_test_.fake_shortcuts()[0]; 1922 const arc::mojom::ShortcutInfo& shortcut = arc_test_.fake_shortcuts()[0];
1929 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); 1923 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1);
1930 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); 1924 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2);
1931 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); 1925 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3);
1932 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut); 1926 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(); 1996 arc_test_.app_instance()->launch_requests()[1].get();
2003 1997
2004 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || 1998 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) ||
2005 (request1->IsForApp(app3) && request2->IsForApp(app2))); 1999 (request1->IsForApp(app3) && request2->IsForApp(app2)));
2006 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(), 2000 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(),
2007 shortcut.intent_uri); 2001 shortcut.intent_uri);
2008 } 2002 }
2009 2003
2010 // Ensure the deferred controller does not override the active app controller 2004 // Ensure the deferred controller does not override the active app controller
2011 // (crbug.com/701152). 2005 // (crbug.com/701152).
2012 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) { 2006 TEST_P(ChromeLauncherControllerWithArcTest, ArcDeferredLaunchForActiveApp) {
2013 InitLauncherController(); 2007 InitLauncherController();
2014 SendListOfArcApps(); 2008 SendListOfArcApps();
2015 arc_test_.StopArcInstance(); 2009 arc_test_.StopArcInstance();
2016 2010
2017 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; 2011 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0];
2018 const std::string app_id = ArcAppTest::GetAppId(app); 2012 const std::string app_id = ArcAppTest::GetAppId(app);
2019 2013
2020 launcher_controller_->PinAppWithID(app_id); 2014 launcher_controller_->PinAppWithID(app_id);
2021 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 2015 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
2022 const ash::ShelfID shelf_id = 2016 const ash::ShelfID shelf_id =
(...skipping 25 matching lines...) Expand all
2048 item_index = model_->ItemIndexByID(shelf_id); 2042 item_index = model_->ItemIndexByID(shelf_id);
2049 ASSERT_GE(item_index, 0); 2043 ASSERT_GE(item_index, 0);
2050 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); 2044 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED);
2051 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP); 2045 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP);
2052 2046
2053 // Now launch request should not be ignored. 2047 // Now launch request should not be ignored.
2054 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); 2048 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
2055 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 2049 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
2056 } 2050 }
2057 2051
2058 TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { 2052 TEST_P(ChromeLauncherControllerMultiProfileWithArcTest, ArcMultiUser) {
2059 SendListOfArcApps(); 2053 SendListOfArcApps();
2060 2054
2061 InitLauncherController(); 2055 InitLauncherController();
2062 // TODO(crbug.com/654622): This test breaks with a non-null static instance. 2056 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2063 ChromeLauncherControllerImpl::set_instance_for_test(nullptr); 2057 ChromeLauncherController::set_instance_for_test(nullptr);
2064 2058
2065 SetLauncherControllerHelper(new TestLauncherControllerHelper); 2059 SetLauncherControllerHelper(new TestLauncherControllerHelper);
2066 2060
2067 // App1 exists all the time. 2061 // App1 exists all the time.
2068 // App2 is created when primary user is active and destroyed when secondary 2062 // App2 is created when primary user is active and destroyed when secondary
2069 // user is active. 2063 // user is active.
2070 // App3 created when secondary user is active. 2064 // App3 created when secondary user is active.
2071 2065
2072 const std::string user2 = "user2"; 2066 const std::string user2 = "user2";
2073 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2067 TestingProfile* profile2 = CreateMultiUserProfile(user2);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 EXPECT_EQ(ash::kInvalidShelfID, 2117 EXPECT_EQ(ash::kInvalidShelfID,
2124 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 2118 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2125 EXPECT_NE(ash::kInvalidShelfID, 2119 EXPECT_NE(ash::kInvalidShelfID,
2126 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 2120 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
2127 2121
2128 // Close active window to let test passes. 2122 // Close active window to let test passes.
2129 arc_window1->CloseNow(); 2123 arc_window1->CloseNow();
2130 arc_window3->CloseNow(); 2124 arc_window3->CloseNow();
2131 } 2125 }
2132 2126
2133 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { 2127 TEST_P(ChromeLauncherControllerWithArcTest, ArcRunningApp) {
2134 InitLauncherController(); 2128 InitLauncherController();
2135 2129
2136 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2130 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2137 SendListOfArcApps(); 2131 SendListOfArcApps();
2138 EXPECT_EQ(ash::kInvalidShelfID, 2132 EXPECT_EQ(ash::kInvalidShelfID,
2139 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2133 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2140 2134
2141 // Normal flow, create/destroy tasks. 2135 // Normal flow, create/destroy tasks.
2142 std::string window_app_id1("org.chromium.arc.1"); 2136 std::string window_app_id1("org.chromium.arc.1");
2143 std::string window_app_id2("org.chromium.arc.2"); 2137 std::string window_app_id2("org.chromium.arc.2");
(...skipping 22 matching lines...) Expand all
2166 EXPECT_NE(ash::kInvalidShelfID, 2160 EXPECT_NE(ash::kInvalidShelfID,
2167 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2161 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2168 arc_test_.StopArcInstance(); 2162 arc_test_.StopArcInstance();
2169 base::RunLoop().RunUntilIdle(); 2163 base::RunLoop().RunUntilIdle();
2170 EXPECT_EQ(ash::kInvalidShelfID, 2164 EXPECT_EQ(ash::kInvalidShelfID,
2171 launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2165 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2172 } 2166 }
2173 2167
2174 // Test race creation/deletion of ARC app. 2168 // Test race creation/deletion of ARC app.
2175 // TODO(khmel): Remove after moving everything to wayland protocol. 2169 // TODO(khmel): Remove after moving everything to wayland protocol.
2176 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { 2170 TEST_P(ChromeLauncherControllerWithArcTest, ArcRaceCreateClose) {
2177 InitLauncherController(); 2171 InitLauncherController();
2178 2172
2179 const std::string arc_app_id1 = 2173 const std::string arc_app_id1 =
2180 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2174 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2181 const std::string arc_app_id2 = 2175 const std::string arc_app_id2 =
2182 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 2176 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
2183 SendListOfArcApps(); 2177 SendListOfArcApps();
2184 2178
2185 // ARC window created before and closed after mojom notification. 2179 // ARC window created before and closed after mojom notification.
2186 std::string window_app_id1("org.chromium.arc.1"); 2180 std::string window_app_id1("org.chromium.arc.1");
(...skipping 26 matching lines...) Expand all
2213 arc_window->Close(); 2207 arc_window->Close();
2214 base::RunLoop().RunUntilIdle(); 2208 base::RunLoop().RunUntilIdle();
2215 // Closing window does not close shelf item. It is closed on task destroy. 2209 // Closing window does not close shelf item. It is closed on task destroy.
2216 EXPECT_NE(ash::kInvalidShelfID, 2210 EXPECT_NE(ash::kInvalidShelfID,
2217 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 2211 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2218 arc_test_.app_instance()->SendTaskDestroyed(2); 2212 arc_test_.app_instance()->SendTaskDestroyed(2);
2219 EXPECT_EQ(ash::kInvalidShelfID, 2213 EXPECT_EQ(ash::kInvalidShelfID,
2220 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 2214 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2221 } 2215 }
2222 2216
2223 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { 2217 TEST_P(ChromeLauncherControllerWithArcTest, ArcWindowRecreation) {
2224 InitLauncherController(); 2218 InitLauncherController();
2225 2219
2226 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2220 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2227 SendListOfArcApps(); 2221 SendListOfArcApps();
2228 2222
2229 std::string window_app_id("org.chromium.arc.1"); 2223 std::string window_app_id("org.chromium.arc.1");
2230 views::Widget* arc_window = CreateArcWindow(window_app_id); 2224 views::Widget* arc_window = CreateArcWindow(window_app_id);
2231 ASSERT_TRUE(arc_window); 2225 ASSERT_TRUE(arc_window);
2232 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], 2226 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0],
2233 std::string()); 2227 std::string());
2234 const ash::ShelfID shelf_id = 2228 const ash::ShelfID shelf_id =
2235 launcher_controller_->GetShelfIDForAppID(arc_app_id); 2229 launcher_controller_->GetShelfIDForAppID(arc_app_id);
2236 EXPECT_NE(ash::kInvalidShelfID, shelf_id); 2230 EXPECT_NE(ash::kInvalidShelfID, shelf_id);
2237 2231
2238 for (int i = 0; i < 3; ++i) { 2232 for (int i = 0; i < 3; ++i) {
2239 arc_window->Close(); 2233 arc_window->Close();
2240 base::RunLoop().RunUntilIdle(); 2234 base::RunLoop().RunUntilIdle();
2241 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2235 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
2242 2236
2243 arc_window = CreateArcWindow(window_app_id); 2237 arc_window = CreateArcWindow(window_app_id);
2244 ASSERT_TRUE(arc_window); 2238 ASSERT_TRUE(arc_window);
2245 base::RunLoop().RunUntilIdle(); 2239 base::RunLoop().RunUntilIdle();
2246 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2240 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
2247 } 2241 }
2248 } 2242 }
2249 2243
2250 // Validate that ARC app is pinned correctly and pin is removed automatically 2244 // Validate that ARC app is pinned correctly and pin is removed automatically
2251 // once app is uninstalled. 2245 // once app is uninstalled.
2252 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { 2246 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPin) {
2253 InitLauncherController(); 2247 InitLauncherController();
2254 2248
2255 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2249 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2256 2250
2257 SendListOfArcApps(); 2251 SendListOfArcApps();
2258 extension_service_->AddExtension(extension1_.get()); 2252 extension_service_->AddExtension(extension1_.get());
2259 extension_service_->AddExtension(extension2_.get()); 2253 extension_service_->AddExtension(extension2_.get());
2260 2254
2261 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 2255 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
2262 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); 2256 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()); 2281 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
2288 EnablePlayStore(false); 2282 EnablePlayStore(false);
2289 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 2283 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
2290 EnablePlayStore(true); 2284 EnablePlayStore(true);
2291 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 2285 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
2292 SendListOfArcApps(); 2286 SendListOfArcApps();
2293 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 2287 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
2294 } 2288 }
2295 2289
2296 // Validates that ARC app pins persist across OptOut/OptIn. 2290 // Validates that ARC app pins persist across OptOut/OptIn.
2297 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { 2291 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPinOptOutOptIn) {
2298 InitLauncherController(); 2292 InitLauncherController();
2299 2293
2300 const std::string arc_app_id1 = 2294 const std::string arc_app_id1 =
2301 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2295 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2302 const std::string arc_app_id2 = 2296 const std::string arc_app_id2 =
2303 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 2297 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
2304 2298
2305 SendListOfArcApps(); 2299 SendListOfArcApps();
2306 extension_service_->AddExtension(extension1_.get()); 2300 extension_service_->AddExtension(extension1_.get());
2307 extension_service_->AddExtension(extension2_.get()); 2301 extension_service_->AddExtension(extension2_.get());
(...skipping 29 matching lines...) Expand all
2337 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); 2331 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
2338 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 2332 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2339 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); 2333 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2));
2340 2334
2341 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", 2335 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
2342 GetPinnedAppStatus()); 2336 GetPinnedAppStatus());
2343 } 2337 }
2344 2338
2345 // Check that with multi profile V1 apps are properly added / removed from the 2339 // Check that with multi profile V1 apps are properly added / removed from the
2346 // shelf. 2340 // shelf.
2347 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2341 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2348 V1AppUpdateOnUserSwitch) { 2342 V1AppUpdateOnUserSwitch) {
2349 // Create a browser item in the LauncherController. 2343 // Create a browser item in the LauncherController.
2350 InitLauncherController(); 2344 InitLauncherController();
2351 2345
2352 EXPECT_EQ(2, model_->item_count()); 2346 EXPECT_EQ(2, model_->item_count());
2353 { 2347 {
2354 // Create a "windowed gmail app". 2348 // Create a "windowed gmail app".
2355 std::unique_ptr<V1App> v1_app( 2349 std::unique_ptr<V1App> v1_app(
2356 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); 2350 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url));
2357 EXPECT_EQ(3, model_->item_count()); 2351 EXPECT_EQ(3, model_->item_count());
(...skipping 10 matching lines...) Expand all
2368 2362
2369 // After switching back the item should be back. 2363 // After switching back the item should be back.
2370 SwitchActiveUser(account_id); 2364 SwitchActiveUser(account_id);
2371 EXPECT_EQ(3, model_->item_count()); 2365 EXPECT_EQ(3, model_->item_count());
2372 // Note we destroy now the gmail app with the closure end. 2366 // Note we destroy now the gmail app with the closure end.
2373 } 2367 }
2374 EXPECT_EQ(2, model_->item_count()); 2368 EXPECT_EQ(2, model_->item_count());
2375 } 2369 }
2376 2370
2377 // Check edge cases with multi profile V1 apps in the shelf. 2371 // Check edge cases with multi profile V1 apps in the shelf.
2378 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2372 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2379 V1AppUpdateOnUserSwitchEdgecases) { 2373 V1AppUpdateOnUserSwitchEdgecases) {
2380 // Create a browser item in the LauncherController. 2374 // Create a browser item in the LauncherController.
2381 InitLauncherController(); 2375 InitLauncherController();
2382 2376
2383 // First test: Create an app when the user is not active. 2377 // First test: Create an app when the user is not active.
2384 std::string user2 = "user2"; 2378 std::string user2 = "user2";
2385 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2379 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2386 const AccountId account_id2( 2380 const AccountId account_id2(
2387 multi_user_util::GetAccountIdFromProfile(profile2)); 2381 multi_user_util::GetAccountIdFromProfile(profile2));
2388 const AccountId account_id( 2382 const AccountId account_id(
(...skipping 15 matching lines...) Expand all
2404 // Note: the closure ends and the browser will go away. 2398 // Note: the closure ends and the browser will go away.
2405 } 2399 }
2406 EXPECT_EQ(2, model_->item_count()); 2400 EXPECT_EQ(2, model_->item_count());
2407 SwitchActiveUser(account_id2); 2401 SwitchActiveUser(account_id2);
2408 EXPECT_EQ(2, model_->item_count()); 2402 EXPECT_EQ(2, model_->item_count());
2409 SwitchActiveUser(account_id); 2403 SwitchActiveUser(account_id);
2410 EXPECT_EQ(2, model_->item_count()); 2404 EXPECT_EQ(2, model_->item_count());
2411 } 2405 }
2412 2406
2413 // Check edge case where a visiting V1 app gets closed (crbug.com/321374). 2407 // Check edge case where a visiting V1 app gets closed (crbug.com/321374).
2414 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2408 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2415 V1CloseOnVisitingDesktop) { 2409 V1CloseOnVisitingDesktop) {
2416 // Create a browser item in the LauncherController. 2410 // Create a browser item in the LauncherController.
2417 InitLauncherController(); 2411 InitLauncherController();
2418 2412
2419 chrome::MultiUserWindowManager* manager = 2413 chrome::MultiUserWindowManager* manager =
2420 chrome::MultiUserWindowManager::GetInstance(); 2414 chrome::MultiUserWindowManager::GetInstance();
2421 2415
2422 // First create an app when the user is active. 2416 // First create an app when the user is active.
2423 std::string user2 = "user2"; 2417 std::string user2 = "user2";
2424 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2418 TestingProfile* profile2 = CreateMultiUserProfile(user2);
(...skipping 23 matching lines...) Expand all
2448 // Create a "windowed gmail app". 2442 // Create a "windowed gmail app".
2449 std::unique_ptr<V1App> v1_app(CreateRunningV1App( 2443 std::unique_ptr<V1App> v1_app(CreateRunningV1App(
2450 profile(), extension_misc::kGmailAppId, kGmailLaunchURL)); 2444 profile(), extension_misc::kGmailAppId, kGmailLaunchURL));
2451 EXPECT_EQ(3, model_->item_count()); 2445 EXPECT_EQ(3, model_->item_count());
2452 } 2446 }
2453 SwitchActiveUser(account_id2); 2447 SwitchActiveUser(account_id2);
2454 EXPECT_EQ(2, model_->item_count()); 2448 EXPECT_EQ(2, model_->item_count());
2455 } 2449 }
2456 2450
2457 // Check edge cases with multi profile V1 apps in the shelf. 2451 // Check edge cases with multi profile V1 apps in the shelf.
2458 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2452 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2459 V1AppUpdateOnUserSwitchEdgecases2) { 2453 V1AppUpdateOnUserSwitchEdgecases2) {
2460 // Create a browser item in the LauncherController. 2454 // Create a browser item in the LauncherController.
2461 InitLauncherController(); 2455 InitLauncherController();
2462 2456
2463 // First test: Create an app when the user is not active. 2457 // First test: Create an app when the user is not active.
2464 std::string user2 = "user2"; 2458 std::string user2 = "user2";
2465 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2459 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2466 const AccountId account_id( 2460 const AccountId account_id(
2467 multi_user_util::GetAccountIdFromProfile(profile())); 2461 multi_user_util::GetAccountIdFromProfile(profile()));
2468 const AccountId account_id2( 2462 const AccountId account_id2(
(...skipping 17 matching lines...) Expand all
2486 } 2480 }
2487 EXPECT_EQ(2, model_->item_count()); 2481 EXPECT_EQ(2, model_->item_count());
2488 SwitchActiveUser(account_id); 2482 SwitchActiveUser(account_id);
2489 EXPECT_EQ(2, model_->item_count()); 2483 EXPECT_EQ(2, model_->item_count());
2490 SwitchActiveUser(account_id2); 2484 SwitchActiveUser(account_id2);
2491 EXPECT_EQ(2, model_->item_count()); 2485 EXPECT_EQ(2, model_->item_count());
2492 } 2486 }
2493 2487
2494 // Check that activating an item which is on another user's desktop, will bring 2488 // Check that activating an item which is on another user's desktop, will bring
2495 // it back. 2489 // it back.
2496 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2490 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2497 TestLauncherActivationPullsBackWindow) { 2491 TestLauncherActivationPullsBackWindow) {
2498 // Create a browser item in the LauncherController. 2492 // Create a browser item in the LauncherController.
2499 InitLauncherController(); 2493 InitLauncherController();
2500 chrome::MultiUserWindowManager* manager = 2494 chrome::MultiUserWindowManager* manager =
2501 chrome::MultiUserWindowManager::GetInstance(); 2495 chrome::MultiUserWindowManager::GetInstance();
2502 2496
2503 // Create a second test profile. The first is the one in profile() created in 2497 // Create a second test profile. The first is the one in profile() created in
2504 // BrowserWithTestWindowTest::SetUp(). 2498 // BrowserWithTestWindowTest::SetUp().
2505 // No need to add the profiles to the MultiUserWindowManager here. 2499 // No need to add the profiles to the MultiUserWindowManager here.
2506 // CreateMultiUserProfile() already does that. 2500 // CreateMultiUserProfile() already does that.
(...skipping 17 matching lines...) Expand all
2524 // does pull it back to that user. 2518 // does pull it back to that user.
2525 manager->ShowWindowForUser( 2519 manager->ShowWindowForUser(
2526 window, multi_user_util::GetAccountIdFromProfile(profile2)); 2520 window, multi_user_util::GetAccountIdFromProfile(profile2));
2527 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user)); 2521 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user));
2528 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); 2522 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false);
2529 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); 2523 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user));
2530 } 2524 }
2531 2525
2532 // Check that a running windowed V1 application will be properly pinned and 2526 // Check that a running windowed V1 application will be properly pinned and
2533 // unpinned when the order gets changed through a profile / policy change. 2527 // unpinned when the order gets changed through a profile / policy change.
2534 TEST_F(ChromeLauncherControllerImplTest, 2528 TEST_F(ChromeLauncherControllerTest,
2535 RestoreDefaultAndRunningV1AppsResyncOrder) { 2529 RestoreDefaultAndRunningV1AppsResyncOrder) {
2536 InitLauncherController(); 2530 InitLauncherController();
2537 2531
2538 syncer::SyncChangeList sync_list; 2532 syncer::SyncChangeList sync_list;
2539 InsertAddPinChange(&sync_list, 0, extension1_->id()); 2533 InsertAddPinChange(&sync_list, 0, extension1_->id());
2540 InsertAddPinChange(&sync_list, 1, extension3_->id()); 2534 InsertAddPinChange(&sync_list, 1, extension3_->id());
2541 SendPinChanges(sync_list, true); 2535 SendPinChanges(sync_list, true);
2542 2536
2543 // The shelf layout has always one static item at the beginning (App List). 2537 // The shelf layout has always one static item at the beginning (App List).
2544 extension_service_->AddExtension(extension1_.get()); 2538 extension_service_->AddExtension(extension1_.get());
(...skipping 25 matching lines...) Expand all
2570 SendPinChanges(sync_list2, true); 2564 SendPinChanges(sync_list2, true);
2571 EXPECT_EQ("AppList, Chrome, App3, App1, app2", GetPinnedAppStatus()); 2565 EXPECT_EQ("AppList, Chrome, App3, App1, app2", GetPinnedAppStatus());
2572 2566
2573 // Removing an item should simply close it and everything should shift. 2567 // Removing an item should simply close it and everything should shift.
2574 SendPinChanges(syncer::SyncChangeList(), true); 2568 SendPinChanges(syncer::SyncChangeList(), true);
2575 EXPECT_EQ("AppList, Chrome, App3, app2", GetPinnedAppStatus()); 2569 EXPECT_EQ("AppList, Chrome, App3, app2", GetPinnedAppStatus());
2576 } 2570 }
2577 2571
2578 // Check that a running unpinned V2 application will be properly pinned and 2572 // Check that a running unpinned V2 application will be properly pinned and
2579 // unpinned when the order gets changed through a profile / policy change. 2573 // unpinned when the order gets changed through a profile / policy change.
2580 TEST_F(ChromeLauncherControllerImplTest, 2574 TEST_F(ChromeLauncherControllerTest,
2581 RestoreDefaultAndRunningV2AppsResyncOrder) { 2575 RestoreDefaultAndRunningV2AppsResyncOrder) {
2582 InitLauncherController(); 2576 InitLauncherController();
2583 syncer::SyncChangeList sync_list0; 2577 syncer::SyncChangeList sync_list0;
2584 InsertAddPinChange(&sync_list0, 0, extension1_->id()); 2578 InsertAddPinChange(&sync_list0, 0, extension1_->id());
2585 InsertAddPinChange(&sync_list0, 1, extension3_->id()); 2579 InsertAddPinChange(&sync_list0, 1, extension3_->id());
2586 SendPinChanges(sync_list0, true); 2580 SendPinChanges(sync_list0, true);
2587 // The shelf layout has always one static item at the beginning (app List). 2581 // The shelf layout has always one static item at the beginning (app List).
2588 extension_service_->AddExtension(extension1_.get()); 2582 extension_service_->AddExtension(extension1_.get());
2589 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 2583 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
2590 extension_service_->AddExtension(extension_platform_app_.get()); 2584 extension_service_->AddExtension(extension_platform_app_.get());
(...skipping 24 matching lines...) Expand all
2615 2609
2616 // Removing an item should simply close it and everything should shift. 2610 // Removing an item should simply close it and everything should shift.
2617 syncer::SyncChangeList sync_list3; 2611 syncer::SyncChangeList sync_list3;
2618 InsertAddPinChange(&sync_list3, 0, extension3_->id()); 2612 InsertAddPinChange(&sync_list3, 0, extension3_->id());
2619 SendPinChanges(sync_list3, true); 2613 SendPinChanges(sync_list3, true);
2620 EXPECT_EQ("AppList, Chrome, App3, *platform_app", GetPinnedAppStatus()); 2614 EXPECT_EQ("AppList, Chrome, App3, *platform_app", GetPinnedAppStatus());
2621 } 2615 }
2622 2616
2623 // Each user has a different set of applications pinned. Check that when 2617 // Each user has a different set of applications pinned. Check that when
2624 // switching between the two users, the state gets properly set. 2618 // switching between the two users, the state gets properly set.
2625 TEST_F(ChromeLauncherControllerImplTest, UserSwitchIconRestore) { 2619 TEST_F(ChromeLauncherControllerTest, UserSwitchIconRestore) {
2626 syncer::SyncChangeList user_a; 2620 syncer::SyncChangeList user_a;
2627 syncer::SyncChangeList user_b; 2621 syncer::SyncChangeList user_b;
2628 2622
2629 SetUpMultiUserScenario(&user_a, &user_b); 2623 SetUpMultiUserScenario(&user_a, &user_b);
2630 2624
2631 // Show user 1. 2625 // Show user 1.
2632 SendPinChanges(user_a, true); 2626 SendPinChanges(user_a, true);
2633 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", 2627 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome",
2634 GetPinnedAppStatus()); 2628 GetPinnedAppStatus());
2635 2629
2636 // Show user 2. 2630 // Show user 2.
2637 SendPinChanges(user_b, true); 2631 SendPinChanges(user_b, true);
2638 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus()); 2632 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus());
2639 2633
2640 // Switch back to 1. 2634 // Switch back to 1.
2641 SendPinChanges(user_a, true); 2635 SendPinChanges(user_a, true);
2642 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", 2636 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome",
2643 GetPinnedAppStatus()); 2637 GetPinnedAppStatus());
2644 2638
2645 // Switch back to 2. 2639 // Switch back to 2.
2646 SendPinChanges(user_b, true); 2640 SendPinChanges(user_b, true);
2647 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus()); 2641 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus());
2648 } 2642 }
2649 2643
2650 // Each user has a different set of applications pinned, and one user has an 2644 // 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 2645 // application running. Check that when switching between the two users, the
2652 // state gets properly set. 2646 // state gets properly set.
2653 TEST_F(ChromeLauncherControllerImplTest, 2647 TEST_F(ChromeLauncherControllerTest, UserSwitchIconRestoreWithRunningV2App) {
2654 UserSwitchIconRestoreWithRunningV2App) {
2655 syncer::SyncChangeList user_a; 2648 syncer::SyncChangeList user_a;
2656 syncer::SyncChangeList user_b; 2649 syncer::SyncChangeList user_b;
2657 2650
2658 SetUpMultiUserScenario(&user_a, &user_b); 2651 SetUpMultiUserScenario(&user_a, &user_b);
2659 2652
2660 // Run the platform (V2) app. 2653 // Run the platform (V2) app.
2661 CreateRunningV2App(extension_platform_app_->id()); 2654 CreateRunningV2App(extension_platform_app_->id());
2662 2655
2663 // Show user 1. 2656 // Show user 1.
2664 SendPinChanges(user_a, true); 2657 SendPinChanges(user_a, true);
(...skipping 13 matching lines...) Expand all
2678 // Switch back to 2. 2671 // Switch back to 2.
2679 SendPinChanges(user_b, true); 2672 SendPinChanges(user_b, true);
2680 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", 2673 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app",
2681 GetPinnedAppStatus()); 2674 GetPinnedAppStatus());
2682 } 2675 }
2683 2676
2684 // Each user has a different set of applications pinned, and one user has an 2677 // 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. 2678 // 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. 2679 // Check that when switching between the two users, the state gets properly set.
2687 // There was once a bug associated with this. 2680 // There was once a bug associated with this.
2688 TEST_F(ChromeLauncherControllerImplTest, 2681 TEST_F(ChromeLauncherControllerTest,
2689 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) { 2682 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) {
2690 syncer::SyncChangeList user_a; 2683 syncer::SyncChangeList user_a;
2691 syncer::SyncChangeList user_b; 2684 syncer::SyncChangeList user_b;
2692 SetUpMultiUserScenario(&user_a, &user_b); 2685 SetUpMultiUserScenario(&user_a, &user_b);
2693 2686
2694 // Run the platform (V2) app. 2687 // Run the platform (V2) app.
2695 CreateRunningV2App(extension_platform_app_->id()); 2688 CreateRunningV2App(extension_platform_app_->id());
2696 2689
2697 // Show user 1. 2690 // Show user 1.
2698 SendPinChanges(user_a, true); 2691 SendPinChanges(user_a, true);
2699 SetShelfChromeIconIndex(5); 2692 SetShelfChromeIconIndex(5);
2700 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5", 2693 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5",
2701 GetPinnedAppStatus()); 2694 GetPinnedAppStatus());
2702 2695
2703 // Show user 2. 2696 // Show user 2.
2704 SendPinChanges(user_b, true); 2697 SendPinChanges(user_b, true);
2705 SetShelfChromeIconIndex(4); 2698 SetShelfChromeIconIndex(4);
2706 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", 2699 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app",
2707 GetPinnedAppStatus()); 2700 GetPinnedAppStatus());
2708 2701
2709 // Switch back to 1. 2702 // Switch back to 1.
2710 SendPinChanges(user_a, true); 2703 SendPinChanges(user_a, true);
2711 SetShelfChromeIconIndex(5); 2704 SetShelfChromeIconIndex(5);
2712 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5", 2705 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5",
2713 GetPinnedAppStatus()); 2706 GetPinnedAppStatus());
2714 } 2707 }
2715 2708
2716 TEST_F(ChromeLauncherControllerImplTest, Policy) { 2709 TEST_F(ChromeLauncherControllerTest, Policy) {
2717 extension_service_->AddExtension(extension1_.get()); 2710 extension_service_->AddExtension(extension1_.get());
2718 extension_service_->AddExtension(extension3_.get()); 2711 extension_service_->AddExtension(extension3_.get());
2719 2712
2720 InitLauncherController(); 2713 InitLauncherController();
2721 2714
2722 syncer::SyncChangeList sync_list; 2715 syncer::SyncChangeList sync_list;
2723 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); 2716 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId);
2724 SendPinChanges(sync_list, true); 2717 SendPinChanges(sync_list, true);
2725 2718
2726 base::ListValue policy_value; 2719 base::ListValue policy_value;
(...skipping 25 matching lines...) Expand all
2752 policy_value.Remove(0, NULL); 2745 policy_value.Remove(0, NULL);
2753 profile()->GetTestingPrefService()->SetManagedPref( 2746 profile()->GetTestingPrefService()->SetManagedPref(
2754 prefs::kPolicyPinnedLauncherApps, policy_value.CreateDeepCopy()); 2747 prefs::kPolicyPinnedLauncherApps, policy_value.CreateDeepCopy());
2755 EXPECT_EQ(4, model_->item_count()); 2748 EXPECT_EQ(4, model_->item_count());
2756 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 2749 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
2757 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 2750 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
2758 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 2751 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2759 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 2752 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
2760 } 2753 }
2761 2754
2762 TEST_F(ChromeLauncherControllerImplTest, UnpinWithUninstall) { 2755 TEST_F(ChromeLauncherControllerTest, UnpinWithUninstall) {
2763 extension_service_->AddExtension(extension3_.get()); 2756 extension_service_->AddExtension(extension3_.get());
2764 extension_service_->AddExtension(extension4_.get()); 2757 extension_service_->AddExtension(extension4_.get());
2765 2758
2766 InitLauncherController(); 2759 InitLauncherController();
2767 2760
2768 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 2761 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
2769 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); 2762 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
2770 2763
2771 extension_service_->UnloadExtension(extension3_->id(), 2764 extension_service_->UnloadExtension(extension3_->id(),
2772 UnloadedExtensionInfo::REASON_UNINSTALL); 2765 UnloadedExtensionInfo::REASON_UNINSTALL);
2773 2766
2774 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 2767 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
2775 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); 2768 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
2776 } 2769 }
2777 2770
2778 TEST_F(ChromeLauncherControllerImplTest, SyncUpdates) { 2771 TEST_F(ChromeLauncherControllerTest, SyncUpdates) {
2779 extension_service_->AddExtension(extension2_.get()); 2772 extension_service_->AddExtension(extension2_.get());
2780 extension_service_->AddExtension(extension3_.get()); 2773 extension_service_->AddExtension(extension3_.get());
2781 extension_service_->AddExtension(extension4_.get()); 2774 extension_service_->AddExtension(extension4_.get());
2782 2775
2783 InitLauncherController(); 2776 InitLauncherController();
2784 2777
2785 syncer::SyncChangeList sync_list; 2778 syncer::SyncChangeList sync_list;
2786 InsertAddPinChange(&sync_list, 10, extension_misc::kChromeAppId); 2779 InsertAddPinChange(&sync_list, 10, extension_misc::kChromeAppId);
2787 SendPinChanges(sync_list, true); 2780 SendPinChanges(sync_list, true);
2788 2781
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2836 2829
2837 sync_list.clear(); 2830 sync_list.clear();
2838 InsertRemovePinChange(&sync_list, extension3_->id()); 2831 InsertRemovePinChange(&sync_list, extension3_->id());
2839 InsertRemovePinChange(&sync_list, extension2_->id()); 2832 InsertRemovePinChange(&sync_list, extension2_->id());
2840 SendPinChanges(sync_list, false); 2833 SendPinChanges(sync_list, false);
2841 expected_pinned_apps.clear(); 2834 expected_pinned_apps.clear();
2842 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps); 2835 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2843 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps); 2836 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2844 } 2837 }
2845 2838
2846 TEST_F(ChromeLauncherControllerImplTest, ImportLegacyPin) { 2839 TEST_F(ChromeLauncherControllerTest, ImportLegacyPin) {
2847 // Note extension3_ is actually Gmail app which is default pinned. 2840 // Note extension3_ is actually Gmail app which is default pinned.
2848 extension_service_->AddExtension(extension3_.get()); 2841 extension_service_->AddExtension(extension3_.get());
2849 InitLauncherController(); 2842 InitLauncherController();
2850 2843
2851 // Default pins should contain Gmail. Pref is not syncing now. 2844 // Default pins should contain Gmail. Pref is not syncing now.
2852 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 2845 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
2853 2846
2854 extension_service_->AddExtension(extension2_.get()); 2847 extension_service_->AddExtension(extension2_.get());
2855 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 2848 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
2856 2849
(...skipping 26 matching lines...) Expand all
2883 StartPrefSyncServiceForPins(value); 2876 StartPrefSyncServiceForPins(value);
2884 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); 2877 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus());
2885 2878
2886 // Next Chrome start should preserve pins. 2879 // Next Chrome start should preserve pins.
2887 RecreateLauncherController()->Init(); 2880 RecreateLauncherController()->Init();
2888 StopPrefSyncService(); 2881 StopPrefSyncService();
2889 StartPrefSyncService(syncer::SyncDataList()); 2882 StartPrefSyncService(syncer::SyncDataList());
2890 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); 2883 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus());
2891 } 2884 }
2892 2885
2893 TEST_F(ChromeLauncherControllerImplTest, PendingInsertionOrder) { 2886 TEST_F(ChromeLauncherControllerTest, PendingInsertionOrder) {
2894 extension_service_->AddExtension(extension1_.get()); 2887 extension_service_->AddExtension(extension1_.get());
2895 extension_service_->AddExtension(extension3_.get()); 2888 extension_service_->AddExtension(extension3_.get());
2896 2889
2897 InitLauncherController(); 2890 InitLauncherController();
2898 2891
2899 syncer::SyncChangeList sync_list; 2892 syncer::SyncChangeList sync_list;
2900 InsertAddPinChange(&sync_list, 0, extension1_->id()); 2893 InsertAddPinChange(&sync_list, 0, extension1_->id());
2901 InsertAddPinChange(&sync_list, 1, extension2_->id()); 2894 InsertAddPinChange(&sync_list, 1, extension2_->id());
2902 InsertAddPinChange(&sync_list, 2, extension3_->id()); 2895 InsertAddPinChange(&sync_list, 2, extension3_->id());
2903 SendPinChanges(sync_list, true); 2896 SendPinChanges(sync_list, true);
2904 2897
2905 std::vector<std::string> expected_pinned_apps; 2898 std::vector<std::string> expected_pinned_apps;
2906 expected_pinned_apps.push_back(extension1_->id()); 2899 expected_pinned_apps.push_back(extension1_->id());
2907 expected_pinned_apps.push_back(extension3_->id()); 2900 expected_pinned_apps.push_back(extension3_->id());
2908 std::vector<std::string> actual_pinned_apps; 2901 std::vector<std::string> actual_pinned_apps;
2909 2902
2910 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps); 2903 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2911 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps); 2904 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2912 2905
2913 // Install |extension2| and verify it shows up between the other two. 2906 // Install |extension2| and verify it shows up between the other two.
2914 extension_service_->AddExtension(extension2_.get()); 2907 extension_service_->AddExtension(extension2_.get());
2915 expected_pinned_apps.insert(expected_pinned_apps.begin() + 1, 2908 expected_pinned_apps.insert(expected_pinned_apps.begin() + 1,
2916 extension2_->id()); 2909 extension2_->id());
2917 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps); 2910 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2918 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps); 2911 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2919 } 2912 }
2920 2913
2921 // Ensure |controller| creates the expected menu items for the given shelf item. 2914 // Ensure |controller| creates the expected menu items for the given shelf item.
2922 void CheckAppMenu(ChromeLauncherControllerImpl* controller, 2915 void CheckAppMenu(ChromeLauncherController* controller,
2923 const ash::ShelfItem& item, 2916 const ash::ShelfItem& item,
2924 size_t expected_item_count, 2917 size_t expected_item_count,
2925 base::string16 expected_item_titles[]) { 2918 base::string16 expected_item_titles[]) {
2926 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item); 2919 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item);
2927 ASSERT_EQ(expected_item_count, items.size()); 2920 ASSERT_EQ(expected_item_count, items.size());
2928 for (size_t i = 0; i < expected_item_count; i++) 2921 for (size_t i = 0; i < expected_item_count; i++)
2929 EXPECT_EQ(expected_item_titles[i], items[i]->label); 2922 EXPECT_EQ(expected_item_titles[i], items[i]->label);
2930 } 2923 }
2931 2924
2932 // Check that browsers get reflected correctly in the launcher menu. 2925 // Check that browsers get reflected correctly in the launcher menu.
2933 TEST_F(ChromeLauncherControllerImplTest, BrowserMenuGeneration) { 2926 TEST_F(ChromeLauncherControllerTest, BrowserMenuGeneration) {
2934 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 2927 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
2935 chrome::NewTab(browser()); 2928 chrome::NewTab(browser());
2936 2929
2937 InitLauncherController(); 2930 InitLauncherController();
2938 2931
2939 // Check that the browser list is empty at this time. 2932 // Check that the browser list is empty at this time.
2940 ash::ShelfItem item_browser; 2933 ash::ShelfItem item_browser;
2941 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 2934 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
2942 item_browser.id = 2935 item_browser.id =
2943 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); 2936 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId);
2944 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); 2937 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr);
2945 2938
2946 // Now make the created browser() visible by showing its browser window. 2939 // Now make the created browser() visible by showing its browser window.
2947 browser()->window()->Show(); 2940 browser()->window()->Show();
2948 base::string16 title1 = ASCIIToUTF16("Test1"); 2941 base::string16 title1 = ASCIIToUTF16("Test1");
2949 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); 2942 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1);
2950 base::string16 one_menu_item[] = { title1 }; 2943 base::string16 one_menu_item[] = {title1};
2951 2944
2952 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item); 2945 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item);
2953 2946
2954 // Create one more browser/window and check that one more was added. 2947 // Create one more browser/window and check that one more was added.
2955 std::unique_ptr<Browser> browser2( 2948 std::unique_ptr<Browser> browser2(
2956 CreateBrowserWithTestWindowForProfile(profile())); 2949 CreateBrowserWithTestWindowForProfile(profile()));
2957 chrome::NewTab(browser2.get()); 2950 chrome::NewTab(browser2.get());
2958 browser2->window()->Show(); 2951 browser2->window()->Show();
2959 base::string16 title2 = ASCIIToUTF16("Test2"); 2952 base::string16 title2 = ASCIIToUTF16("Test2");
2960 NavigateAndCommitActiveTabWithTitle(browser2.get(), GURL("http://test2"), 2953 NavigateAndCommitActiveTabWithTitle(browser2.get(), GURL("http://test2"),
2961 title2); 2954 title2);
2962 2955
2963 // Check that the list contains now two entries - make furthermore sure that 2956 // Check that the list contains now two entries - make furthermore sure that
2964 // the active item is the first entry. 2957 // the active item is the first entry.
2965 base::string16 two_menu_items[] = {title1, title2}; 2958 base::string16 two_menu_items[] = {title1, title2};
2966 CheckAppMenu(launcher_controller_, item_browser, 2, two_menu_items); 2959 CheckAppMenu(launcher_controller_, item_browser, 2, two_menu_items);
2967 2960
2968 // Apparently we have to close all tabs we have. 2961 // Apparently we have to close all tabs we have.
2969 chrome::CloseTab(browser2.get()); 2962 chrome::CloseTab(browser2.get());
2970 } 2963 }
2971 2964
2972 // Check the multi profile case where only user related browsers should show up. 2965 // Check the multi profile case where only user related browsers should show up.
2973 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2966 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
2974 BrowserMenuGenerationTwoUsers) { 2967 BrowserMenuGenerationTwoUsers) {
2975 // Create a browser item in the LauncherController. 2968 // Create a browser item in the LauncherController.
2976 InitLauncherController(); 2969 InitLauncherController();
2977 2970
2978 ash::ShelfItem item_browser; 2971 ash::ShelfItem item_browser;
2979 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 2972 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
2980 item_browser.id = 2973 item_browser.id =
2981 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); 2974 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId);
2982 2975
2983 // Check that the menu is empty. 2976 // Check that the menu is empty.
2984 chrome::NewTab(browser()); 2977 chrome::NewTab(browser());
2985 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); 2978 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr);
2986 2979
2987 // Show the created |browser()| by showing its window. 2980 // Show the created |browser()| by showing its window.
2988 browser()->window()->Show(); 2981 browser()->window()->Show();
2989 base::string16 title1 = ASCIIToUTF16("Test1"); 2982 base::string16 title1 = ASCIIToUTF16("Test1");
2990 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); 2983 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1);
2991 base::string16 one_menu_item1[] = { title1 }; 2984 base::string16 one_menu_item1[] = {title1};
2992 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1); 2985 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1);
2993 2986
2994 // Create a browser for another user and check that it is not included in the 2987 // Create a browser for another user and check that it is not included in the
2995 // users running browser list. 2988 // users running browser list.
2996 std::string user2 = "user2"; 2989 std::string user2 = "user2";
2997 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2990 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2998 const AccountId account_id2( 2991 const AccountId account_id2(
2999 multi_user_util::GetAccountIdFromProfile(profile2)); 2992 multi_user_util::GetAccountIdFromProfile(profile2));
3000 std::unique_ptr<Browser> browser2( 2993 std::unique_ptr<Browser> browser2(
3001 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2")); 2994 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2"));
3002 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) }; 2995 base::string16 one_menu_item2[] = {ASCIIToUTF16(user2)};
3003 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1); 2996 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1);
3004 2997
3005 // Switch to the other user and make sure that only that browser window gets 2998 // Switch to the other user and make sure that only that browser window gets
3006 // shown. 2999 // shown.
3007 SwitchActiveUser(account_id2); 3000 SwitchActiveUser(account_id2);
3008 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2); 3001 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2);
3009 3002
3010 // Transferred browsers of other users should not show up in the list. 3003 // Transferred browsers of other users should not show up in the list.
3011 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( 3004 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(
3012 browser()->window()->GetNativeWindow(), account_id2); 3005 browser()->window()->GetNativeWindow(), account_id2);
3013 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2); 3006 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2);
3014 3007
3015 chrome::CloseTab(browser2.get()); 3008 chrome::CloseTab(browser2.get());
3016 } 3009 }
3017 3010
3018 // Check that V1 apps are correctly reflected in the launcher menu using the 3011 // Check that V1 apps are correctly reflected in the launcher menu using the
3019 // refocus logic. 3012 // refocus logic.
3020 // Note that the extension matching logic is tested by the extension system 3013 // Note that the extension matching logic is tested by the extension system
3021 // and does not need a separate test here. 3014 // and does not need a separate test here.
3022 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuGeneration) { 3015 TEST_F(ChromeLauncherControllerTest, V1AppMenuGeneration) {
3023 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 3016 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
3024 EXPECT_EQ(0, browser()->tab_strip_model()->count()); 3017 EXPECT_EQ(0, browser()->tab_strip_model()->count());
3025 3018
3026 InitLauncherControllerWithBrowser(); 3019 InitLauncherControllerWithBrowser();
3027 3020
3028 // The model should only contain the browser shortcut and app list items. 3021 // The model should only contain the browser shortcut and app list items.
3029 EXPECT_EQ(2, model_->item_count()); 3022 EXPECT_EQ(2, model_->item_count());
3030 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 3023 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
3031 3024
3032 // Installing |extension3_| adds it to the launcher. 3025 // Installing |extension3_| adds it to the launcher.
(...skipping 13 matching lines...) Expand all
3046 3039
3047 ash::ShelfItem item_gmail; 3040 ash::ShelfItem item_gmail;
3048 item_gmail.type = ash::TYPE_PINNED_APP; 3041 item_gmail.type = ash::TYPE_PINNED_APP;
3049 item_gmail.id = gmail_id; 3042 item_gmail.id = gmail_id;
3050 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3043 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3051 3044
3052 // Set the gmail URL to a new tab. 3045 // Set the gmail URL to a new tab.
3053 base::string16 title1 = ASCIIToUTF16("Test1"); 3046 base::string16 title1 = ASCIIToUTF16("Test1");
3054 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3047 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3055 3048
3056 base::string16 one_menu_item[] = { title1 }; 3049 base::string16 one_menu_item[] = {title1};
3057 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); 3050 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item);
3058 3051
3059 // Create one empty tab. 3052 // Create one empty tab.
3060 chrome::NewTab(browser()); 3053 chrome::NewTab(browser());
3061 base::string16 title2 = ASCIIToUTF16("Test2"); 3054 base::string16 title2 = ASCIIToUTF16("Test2");
3062 NavigateAndCommitActiveTabWithTitle( 3055 NavigateAndCommitActiveTabWithTitle(browser(), GURL("https://bla"), title2);
3063 browser(),
3064 GURL("https://bla"),
3065 title2);
3066 3056
3067 // and another one with another gmail instance. 3057 // and another one with another gmail instance.
3068 chrome::NewTab(browser()); 3058 chrome::NewTab(browser());
3069 base::string16 title3 = ASCIIToUTF16("Test3"); 3059 base::string16 title3 = ASCIIToUTF16("Test3");
3070 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title3); 3060 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title3);
3071 base::string16 two_menu_items[] = {title1, title3}; 3061 base::string16 two_menu_items[] = {title1, title3};
3072 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); 3062 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items);
3073 3063
3074 // Even though the item is in the V1 app list, it should also be in the 3064 // Even though the item is in the V1 app list, it should also be in the
3075 // browser list. 3065 // browser list.
3076 base::string16 browser_menu_item[] = {title3}; 3066 base::string16 browser_menu_item[] = {title3};
3077 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item); 3067 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item);
3078 3068
3079 // Test that closing of (all) the item(s) does work (and all menus get 3069 // Test that closing of (all) the item(s) does work (and all menus get
3080 // updated properly). 3070 // updated properly).
3081 launcher_controller_->Close(item_gmail.id); 3071 launcher_controller_->Close(item_gmail.id);
3082 3072
3083 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3073 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3084 base::string16 browser_menu_item2[] = { title2 }; 3074 base::string16 browser_menu_item2[] = {title2};
3085 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item2); 3075 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item2);
3086 } 3076 }
3087 3077
3088 // Check the multi profile case where only user related apps should show up. 3078 // Check the multi profile case where only user related apps should show up.
3089 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3079 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3090 V1AppMenuGenerationTwoUsers) { 3080 V1AppMenuGenerationTwoUsers) {
3091 // Create a browser item in the LauncherController. 3081 // Create a browser item in the LauncherController.
3092 InitLauncherController(); 3082 InitLauncherController();
3093 chrome::NewTab(browser()); 3083 chrome::NewTab(browser());
3094 3084
3095 // Installing |extension3_| adds it to the launcher. 3085 // Installing |extension3_| adds it to the launcher.
3096 ash::ShelfID gmail_id = model_->next_id(); 3086 ash::ShelfID gmail_id = model_->next_id();
3097 extension_service_->AddExtension(extension3_.get()); 3087 extension_service_->AddExtension(extension3_.get());
3098 EXPECT_EQ(3, model_->item_count()); 3088 EXPECT_EQ(3, model_->item_count());
3099 int gmail_index = model_->ItemIndexByID(gmail_id); 3089 int gmail_index = model_->ItemIndexByID(gmail_id);
3100 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); 3090 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type);
3101 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 3091 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
3102 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3092 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3103 3093
3104 // Check the menu content. 3094 // Check the menu content.
3105 ash::ShelfItem item_browser; 3095 ash::ShelfItem item_browser;
3106 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 3096 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
3107 item_browser.id = 3097 item_browser.id =
3108 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); 3098 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId);
3109 3099
3110 ash::ShelfItem item_gmail; 3100 ash::ShelfItem item_gmail;
3111 item_gmail.type = ash::TYPE_PINNED_APP; 3101 item_gmail.type = ash::TYPE_PINNED_APP;
3112 item_gmail.id = gmail_id; 3102 item_gmail.id = gmail_id;
3113 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3103 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3114 3104
3115 // Set the gmail URL to a new tab. 3105 // Set the gmail URL to a new tab.
3116 base::string16 title1 = ASCIIToUTF16("Test1"); 3106 base::string16 title1 = ASCIIToUTF16("Test1");
3117 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3107 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3118 3108
3119 base::string16 one_menu_item[] = { title1 }; 3109 base::string16 one_menu_item[] = {title1};
3120 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); 3110 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item);
3121 3111
3122 // Create a second profile and switch to that user. 3112 // Create a second profile and switch to that user.
3123 std::string user2 = "user2"; 3113 std::string user2 = "user2";
3124 TestingProfile* profile2 = CreateMultiUserProfile(user2); 3114 TestingProfile* profile2 = CreateMultiUserProfile(user2);
3125 const AccountId account_id2( 3115 const AccountId account_id2(
3126 multi_user_util::GetAccountIdFromProfile(profile2)); 3116 multi_user_util::GetAccountIdFromProfile(profile2));
3127 SwitchActiveUser(account_id2); 3117 SwitchActiveUser(account_id2);
3128 3118
3129 // No item should have content yet. 3119 // No item should have content yet.
3130 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); 3120 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr);
3131 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3121 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3132 3122
3133 // Transfer the browser of the first user - it should still not show up. 3123 // Transfer the browser of the first user - it should still not show up.
3134 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( 3124 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(
3135 browser()->window()->GetNativeWindow(), account_id2); 3125 browser()->window()->GetNativeWindow(), account_id2);
3136 3126
3137 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); 3127 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr);
3138 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); 3128 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr);
3139 } 3129 }
3140 3130
3141 // Check that V2 applications are creating items properly in the launcher when 3131 // Check that V2 applications are creating items properly in the launcher when
3142 // instantiated by the current user. 3132 // instantiated by the current user.
3143 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3133 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3144 V2AppHandlingTwoUsers) { 3134 V2AppHandlingTwoUsers) {
3145 InitLauncherController(); 3135 InitLauncherController();
3146 // Create a profile for our second user (will be destroyed by the framework). 3136 // Create a profile for our second user (will be destroyed by the framework).
3147 TestingProfile* profile2 = CreateMultiUserProfile("user2"); 3137 TestingProfile* profile2 = CreateMultiUserProfile("user2");
3148 const AccountId account_id( 3138 const AccountId account_id(
3149 multi_user_util::GetAccountIdFromProfile(profile())); 3139 multi_user_util::GetAccountIdFromProfile(profile()));
3150 const AccountId account_id2( 3140 const AccountId account_id2(
3151 multi_user_util::GetAccountIdFromProfile(profile2)); 3141 multi_user_util::GetAccountIdFromProfile(profile2));
3152 // Check that there is a browser and a app launcher. 3142 // Check that there is a browser and a app launcher.
3153 EXPECT_EQ(2, model_->item_count()); 3143 EXPECT_EQ(2, model_->item_count());
3154 3144
3155 // Add a v2 app. 3145 // Add a v2 app.
3156 V2App v2_app(profile(), extension1_.get()); 3146 V2App v2_app(profile(), extension1_.get());
3157 EXPECT_EQ(3, model_->item_count()); 3147 EXPECT_EQ(3, model_->item_count());
3158 3148
3159 // After switching users the item should go away. 3149 // After switching users the item should go away.
3160 SwitchActiveUser(account_id2); 3150 SwitchActiveUser(account_id2);
3161 EXPECT_EQ(2, model_->item_count()); 3151 EXPECT_EQ(2, model_->item_count());
3162 3152
3163 // And it should come back when switching back. 3153 // And it should come back when switching back.
3164 SwitchActiveUser(account_id); 3154 SwitchActiveUser(account_id);
3165 EXPECT_EQ(3, model_->item_count()); 3155 EXPECT_EQ(3, model_->item_count());
3166 } 3156 }
3167 3157
3168 // Check that V2 applications are creating items properly in edge cases: 3158 // 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 3159 // a background user creates a V2 app, gets active and inactive again and then
3170 // deletes the app. 3160 // deletes the app.
3171 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3161 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3172 V2AppHandlingTwoUsersEdgeCases) { 3162 V2AppHandlingTwoUsersEdgeCases) {
3173 InitLauncherController(); 3163 InitLauncherController();
3174 // Create a profile for our second user (will be destroyed by the framework). 3164 // Create a profile for our second user (will be destroyed by the framework).
3175 TestingProfile* profile2 = CreateMultiUserProfile("user2"); 3165 TestingProfile* profile2 = CreateMultiUserProfile("user2");
3176 const AccountId account_id( 3166 const AccountId account_id(
3177 multi_user_util::GetAccountIdFromProfile(profile())); 3167 multi_user_util::GetAccountIdFromProfile(profile()));
3178 const AccountId account_id2( 3168 const AccountId account_id2(
3179 multi_user_util::GetAccountIdFromProfile(profile2)); 3169 multi_user_util::GetAccountIdFromProfile(profile2));
3180 // Check that there is a browser and a app launcher. 3170 // Check that there is a browser and a app launcher.
3181 EXPECT_EQ(2, model_->item_count()); 3171 EXPECT_EQ(2, model_->item_count());
(...skipping 22 matching lines...) Expand all
3204 EXPECT_EQ(2, model_->item_count()); 3194 EXPECT_EQ(2, model_->item_count());
3205 3195
3206 // Switching then back to the default user should not show the additional item 3196 // Switching then back to the default user should not show the additional item
3207 // anymore. 3197 // anymore.
3208 SwitchActiveUser(account_id); 3198 SwitchActiveUser(account_id);
3209 EXPECT_EQ(2, model_->item_count()); 3199 EXPECT_EQ(2, model_->item_count());
3210 } 3200 }
3211 3201
3212 // Check that V2 applications will be made visible on the target desktop if 3202 // Check that V2 applications will be made visible on the target desktop if
3213 // another window of the same type got previously teleported there. 3203 // another window of the same type got previously teleported there.
3214 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3204 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3215 V2AppFollowsTeleportedWindow) { 3205 V2AppFollowsTeleportedWindow) {
3216 InitLauncherController(); 3206 InitLauncherController();
3217 chrome::MultiUserWindowManager* manager = 3207 chrome::MultiUserWindowManager* manager =
3218 chrome::MultiUserWindowManager::GetInstance(); 3208 chrome::MultiUserWindowManager::GetInstance();
3219 3209
3220 // Create and add three users / profiles, and go to #1's desktop. 3210 // Create and add three users / profiles, and go to #1's desktop.
3221 TestingProfile* profile1 = CreateMultiUserProfile("user-1"); 3211 TestingProfile* profile1 = CreateMultiUserProfile("user-1");
3222 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); 3212 TestingProfile* profile2 = CreateMultiUserProfile("user-2");
3223 TestingProfile* profile3 = CreateMultiUserProfile("user-3"); 3213 TestingProfile* profile3 = CreateMultiUserProfile("user-3");
3224 const AccountId account_id1( 3214 const AccountId account_id1(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 SwitchActiveUser(account_id2); 3265 SwitchActiveUser(account_id2);
3276 v2_app_1.window()->Hide(); 3266 v2_app_1.window()->Hide();
3277 V2App v2_app_6(profile1, extension1_.get()); 3267 V2App v2_app_6(profile1, extension1_.get());
3278 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); 3268 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible());
3279 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); 3269 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible());
3280 EXPECT_TRUE(v2_app_6.window()->GetNativeWindow()->IsVisible()); 3270 EXPECT_TRUE(v2_app_6.window()->GetNativeWindow()->IsVisible());
3281 } 3271 }
3282 3272
3283 // Check that V2 applications hide correctly on the shelf when the app window 3273 // Check that V2 applications hide correctly on the shelf when the app window
3284 // is hidden. 3274 // is hidden.
3285 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 3275 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3286 V2AppHiddenWindows) { 3276 V2AppHiddenWindows) {
3287 InitLauncherController(); 3277 InitLauncherController();
3288 3278
3289 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); 3279 TestingProfile* profile2 = CreateMultiUserProfile("user-2");
3290 const AccountId account_id( 3280 const AccountId account_id(
3291 multi_user_util::GetAccountIdFromProfile(profile())); 3281 multi_user_util::GetAccountIdFromProfile(profile()));
3292 const AccountId account_id2( 3282 const AccountId account_id2(
3293 multi_user_util::GetAccountIdFromProfile(profile2)); 3283 multi_user_util::GetAccountIdFromProfile(profile2));
3294 SwitchActiveUser(account_id); 3284 SwitchActiveUser(account_id);
3295 EXPECT_EQ(2, model_->item_count()); 3285 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); 3337 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE);
3348 EXPECT_EQ(3, model_->item_count()); 3338 EXPECT_EQ(3, model_->item_count());
3349 3339
3350 v2_app_1.window()->Hide(); 3340 v2_app_1.window()->Hide();
3351 v2_app_2.window()->Hide(); 3341 v2_app_2.window()->Hide();
3352 EXPECT_EQ(2, model_->item_count()); 3342 EXPECT_EQ(2, model_->item_count());
3353 } 3343 }
3354 } 3344 }
3355 3345
3356 // Checks that the generated menu list properly activates items. 3346 // Checks that the generated menu list properly activates items.
3357 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuExecution) { 3347 TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) {
3358 InitLauncherControllerWithBrowser(); 3348 InitLauncherControllerWithBrowser();
3359 3349
3360 // Add |extension3_| to the launcher and add two items. 3350 // Add |extension3_| to the launcher and add two items.
3361 GURL gmail = GURL("https://mail.google.com/mail/u"); 3351 GURL gmail = GURL("https://mail.google.com/mail/u");
3362 ash::ShelfID gmail_id = model_->next_id(); 3352 ash::ShelfID gmail_id = model_->next_id();
3363 extension_service_->AddExtension(extension3_.get()); 3353 extension_service_->AddExtension(extension3_.get());
3364 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3354 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3365 base::string16 title1 = ASCIIToUTF16("Test1"); 3355 base::string16 title1 = ASCIIToUTF16("Test1");
3366 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3356 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3367 chrome::NewTab(browser()); 3357 chrome::NewTab(browser());
(...skipping 27 matching lines...) Expand all
3395 ash::ShelfApplicationMenuModel menu( 3385 ash::ShelfApplicationMenuModel menu(
3396 base::string16(), 3386 base::string16(),
3397 launcher_controller_->GetAppMenuItemsForTesting(item_gmail), 3387 launcher_controller_->GetAppMenuItemsForTesting(item_gmail),
3398 item_delegate); 3388 item_delegate);
3399 menu.ActivatedAt(3); 3389 menu.ActivatedAt(3);
3400 } 3390 }
3401 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 3391 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
3402 } 3392 }
3403 3393
3404 // Checks that the generated menu list properly deletes items. 3394 // Checks that the generated menu list properly deletes items.
3405 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuDeletionExecution) { 3395 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) {
3406 InitLauncherControllerWithBrowser(); 3396 InitLauncherControllerWithBrowser();
3407 3397
3408 // Add |extension3_| to the launcher and add two items. 3398 // Add |extension3_| to the launcher and add two items.
3409 GURL gmail = GURL("https://mail.google.com/mail/u"); 3399 GURL gmail = GURL("https://mail.google.com/mail/u");
3410 ash::ShelfID gmail_id = model_->next_id(); 3400 ash::ShelfID gmail_id = model_->next_id();
3411 extension_service_->AddExtension(extension3_.get()); 3401 extension_service_->AddExtension(extension3_.get());
3412 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3402 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3413 base::string16 title1 = ASCIIToUTF16("Test1"); 3403 base::string16 title1 = ASCIIToUTF16("Test1");
3414 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3404 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3415 chrome::NewTab(browser()); 3405 chrome::NewTab(browser());
(...skipping 22 matching lines...) Expand all
3438 // Delete one tab through the menu item. 3428 // Delete one tab through the menu item.
3439 { 3429 {
3440 ash::MenuItemList items = 3430 ash::MenuItemList items =
3441 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); 3431 launcher_controller_->GetAppMenuItemsForTesting(item_gmail);
3442 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_SHIFT_DOWN); 3432 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_SHIFT_DOWN);
3443 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); 3433 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count());
3444 } 3434 }
3445 } 3435 }
3446 3436
3447 // Tests that panels create launcher items correctly 3437 // Tests that panels create launcher items correctly
3448 TEST_F(ChromeLauncherControllerImplTest, AppPanels) { 3438 TEST_F(ChromeLauncherControllerTest, AppPanels) {
3449 InitLauncherController(); 3439 InitLauncherController();
3450 model_observer_->clear_counts(); 3440 model_observer_->clear_counts();
3451 const std::string app_id = extension1_->id(); 3441 const std::string app_id = extension1_->id();
3452 3442
3453 // app_icon_loader is owned by ChromeLauncherControllerImpl. 3443 // app_icon_loader is owned by ChromeLauncherController.
3454 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); 3444 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl();
3455 app_icon_loader->AddSupportedApp(app_id); 3445 app_icon_loader->AddSupportedApp(app_id);
3456 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 3446 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
3457 3447
3458 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher. 3448 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher.
3459 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>( 3449 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>(
3460 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL); 3450 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL);
3461 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible()); 3451 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible());
3462 int panel_index = model_observer_->last_index(); 3452 int panel_index = model_observer_->last_index();
3463 EXPECT_EQ(1, model_observer_->added()); 3453 EXPECT_EQ(1, model_observer_->added());
(...skipping 18 matching lines...) Expand all
3482 EXPECT_EQ(1, model_observer_->added()); 3472 EXPECT_EQ(1, model_observer_->added());
3483 model_observer_->clear_counts(); 3473 model_observer_->clear_counts();
3484 3474
3485 app_panel1.reset(); 3475 app_panel1.reset();
3486 app_panel2.reset(); 3476 app_panel2.reset();
3487 EXPECT_EQ(2, model_observer_->removed()); 3477 EXPECT_EQ(2, model_observer_->removed());
3488 } 3478 }
3489 3479
3490 // Tests that the Gmail extension matches more than the app itself claims with 3480 // Tests that the Gmail extension matches more than the app itself claims with
3491 // the manifest file. 3481 // the manifest file.
3492 TEST_F(ChromeLauncherControllerImplTest, GmailMatching) { 3482 TEST_F(ChromeLauncherControllerTest, GmailMatching) {
3493 InitLauncherControllerWithBrowser(); 3483 InitLauncherControllerWithBrowser();
3494 3484
3495 // Create a Gmail browser tab. 3485 // Create a Gmail browser tab.
3496 chrome::NewTab(browser()); 3486 chrome::NewTab(browser());
3497 base::string16 title = ASCIIToUTF16("Test"); 3487 base::string16 title = ASCIIToUTF16("Test");
3498 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title); 3488 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title);
3499 content::WebContents* content = 3489 content::WebContents* content =
3500 browser()->tab_strip_model()->GetActiveWebContents(); 3490 browser()->tab_strip_model()->GetActiveWebContents();
3501 3491
3502 // Check that the launcher controller does not recognize the running app. 3492 // Check that the launcher controller does not recognize the running app.
(...skipping 12 matching lines...) Expand all
3515 3505
3516 // Check also that the app has detected that properly. 3506 // Check also that the app has detected that properly.
3517 ash::ShelfItem item_gmail; 3507 ash::ShelfItem item_gmail;
3518 item_gmail.type = ash::TYPE_PINNED_APP; 3508 item_gmail.type = ash::TYPE_PINNED_APP;
3519 item_gmail.id = gmail_id; 3509 item_gmail.id = gmail_id;
3520 EXPECT_EQ(1U, 3510 EXPECT_EQ(1U,
3521 launcher_controller_->GetAppMenuItemsForTesting(item_gmail).size()); 3511 launcher_controller_->GetAppMenuItemsForTesting(item_gmail).size());
3522 } 3512 }
3523 3513
3524 // Tests that the Gmail extension does not match the offline verison. 3514 // Tests that the Gmail extension does not match the offline verison.
3525 TEST_F(ChromeLauncherControllerImplTest, GmailOfflineMatching) { 3515 TEST_F(ChromeLauncherControllerTest, GmailOfflineMatching) {
3526 InitLauncherControllerWithBrowser(); 3516 InitLauncherControllerWithBrowser();
3527 3517
3528 // Create a Gmail browser tab. 3518 // Create a Gmail browser tab.
3529 chrome::NewTab(browser()); 3519 chrome::NewTab(browser());
3530 base::string16 title = ASCIIToUTF16("Test"); 3520 base::string16 title = ASCIIToUTF16("Test");
3531 NavigateAndCommitActiveTabWithTitle(browser(), 3521 NavigateAndCommitActiveTabWithTitle(browser(), GURL(offline_gmail_url),
3532 GURL(offline_gmail_url),
3533 title); 3522 title);
3534 content::WebContents* content = 3523 content::WebContents* content =
3535 browser()->tab_strip_model()->GetActiveWebContents(); 3524 browser()->tab_strip_model()->GetActiveWebContents();
3536 3525
3537 // Installing |extension3_| adds it to the launcher. 3526 // Installing |extension3_| adds it to the launcher.
3538 ash::ShelfID gmail_id = model_->next_id(); 3527 ash::ShelfID gmail_id = model_->next_id();
3539 extension_service_->AddExtension(extension3_.get()); 3528 extension_service_->AddExtension(extension3_.get());
3540 EXPECT_EQ(3, model_->item_count()); 3529 EXPECT_EQ(3, model_->item_count());
3541 int gmail_index = model_->ItemIndexByID(gmail_id); 3530 int gmail_index = model_->ItemIndexByID(gmail_id);
3542 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); 3531 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type);
3543 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 3532 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
3544 3533
3545 // The content should not be able to be handled by the app. 3534 // The content should not be able to be handled by the app.
3546 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); 3535 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
3547 } 3536 }
3548 3537
3549 // Verify that the launcher item positions are persisted and restored. 3538 // Verify that the launcher item positions are persisted and restored.
3550 TEST_F(ChromeLauncherControllerImplTest, PersistLauncherItemPositions) { 3539 TEST_F(ChromeLauncherControllerTest, PersistLauncherItemPositions) {
3551 InitLauncherController(); 3540 InitLauncherController();
3552 3541
3553 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper; 3542 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper;
3554 SetLauncherControllerHelper(helper); 3543 SetLauncherControllerHelper(helper);
3555 3544
3556 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); 3545 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type);
3557 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[1].type); 3546 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[1].type);
3558 3547
3559 TabStripModel* tab_strip_model = browser()->tab_strip_model(); 3548 TabStripModel* tab_strip_model = browser()->tab_strip_model();
3560 EXPECT_EQ(0, tab_strip_model->count()); 3549 EXPECT_EQ(0, tab_strip_model->count());
(...skipping 20 matching lines...) Expand all
3581 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 3570 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
3582 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); 3571 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type);
3583 3572
3584 RecreateLauncherController(); 3573 RecreateLauncherController();
3585 helper = new TestLauncherControllerHelper(profile()); 3574 helper = new TestLauncherControllerHelper(profile());
3586 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); 3575 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1");
3587 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); 3576 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2");
3588 SetLauncherControllerHelper(helper); 3577 SetLauncherControllerHelper(helper);
3589 launcher_controller_->Init(); 3578 launcher_controller_->Init();
3590 3579
3591 // Check ShelfItems are restored after resetting ChromeLauncherControllerImpl. 3580 // Check ShelfItems are restored after resetting ChromeLauncherController.
3592 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); 3581 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type);
3593 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[1].type); 3582 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[1].type);
3594 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 3583 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
3595 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); 3584 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type);
3596 } 3585 }
3597 3586
3598 // Verifies pinned apps are persisted and restored. 3587 // Verifies pinned apps are persisted and restored.
3599 TEST_F(ChromeLauncherControllerImplTest, PersistPinned) { 3588 TEST_F(ChromeLauncherControllerTest, PersistPinned) {
3600 InitLauncherControllerWithBrowser(); 3589 InitLauncherControllerWithBrowser();
3601 size_t initial_size = model_->items().size(); 3590 size_t initial_size = model_->items().size();
3602 3591
3603 TabStripModel* tab_strip_model = browser()->tab_strip_model(); 3592 TabStripModel* tab_strip_model = browser()->tab_strip_model();
3604 EXPECT_EQ(1, tab_strip_model->count()); 3593 EXPECT_EQ(1, tab_strip_model->count());
3605 3594
3606 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper; 3595 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper;
3607 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); 3596 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1");
3608 SetLauncherControllerHelper(helper); 3597 SetLauncherControllerHelper(helper);
3609 3598
3610 // app_icon_loader is owned by ChromeLauncherControllerImpl. 3599 // app_icon_loader is owned by ChromeLauncherController.
3611 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl; 3600 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl;
3612 app_icon_loader->AddSupportedApp("1"); 3601 app_icon_loader->AddSupportedApp("1");
3613 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 3602 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
3614 EXPECT_EQ(0, app_icon_loader->fetch_count()); 3603 EXPECT_EQ(0, app_icon_loader->fetch_count());
3615 3604
3616 launcher_controller_->PinAppWithID("1"); 3605 launcher_controller_->PinAppWithID("1");
3617 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1"); 3606 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1");
3618 int app_index = model_->ItemIndexByID(id); 3607 int app_index = model_->ItemIndexByID(id);
3619 EXPECT_EQ(1, app_icon_loader->fetch_count()); 3608 EXPECT_EQ(1, app_icon_loader->fetch_count());
3620 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); 3609 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type);
3621 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 3610 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
3622 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 3611 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
3623 EXPECT_EQ(initial_size + 1, model_->items().size()); 3612 EXPECT_EQ(initial_size + 1, model_->items().size());
3624 3613
3625 RecreateLauncherController(); 3614 RecreateLauncherController();
3626 helper = new TestLauncherControllerHelper(profile()); 3615 helper = new TestLauncherControllerHelper(profile());
3627 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); 3616 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1");
3628 SetLauncherControllerHelper(helper); 3617 SetLauncherControllerHelper(helper);
3629 // app_icon_loader is owned by ChromeLauncherControllerImpl. 3618 // app_icon_loader is owned by ChromeLauncherController.
3630 app_icon_loader = new TestAppIconLoaderImpl; 3619 app_icon_loader = new TestAppIconLoaderImpl;
3631 app_icon_loader->AddSupportedApp("1"); 3620 app_icon_loader->AddSupportedApp("1");
3632 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 3621 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
3633 launcher_controller_->Init(); 3622 launcher_controller_->Init();
3634 3623
3635 EXPECT_EQ(1, app_icon_loader->fetch_count()); 3624 EXPECT_EQ(1, app_icon_loader->fetch_count());
3636 ASSERT_EQ(initial_size + 1, model_->items().size()); 3625 ASSERT_EQ(initial_size + 1, model_->items().size());
3637 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 3626 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
3638 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 3627 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
3639 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); 3628 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type);
3640 3629
3641 launcher_controller_->UnpinAppWithID("1"); 3630 launcher_controller_->UnpinAppWithID("1");
3642 ASSERT_EQ(initial_size, model_->items().size()); 3631 ASSERT_EQ(initial_size, model_->items().size());
3643 } 3632 }
3644 3633
3645 TEST_F(ChromeLauncherControllerImplTest, MultipleAppIconLoaders) { 3634 TEST_F(ChromeLauncherControllerTest, MultipleAppIconLoaders) {
3646 InitLauncherControllerWithBrowser(); 3635 InitLauncherControllerWithBrowser();
3647 3636
3648 const std::string app_id1 = extension1_->id(); 3637 const std::string app_id1 = extension1_->id();
3649 const std::string app_id2 = extension2_->id(); 3638 const std::string app_id2 = extension2_->id();
3650 const std::string app_id3 = extension3_->id(); 3639 const std::string app_id3 = extension3_->id();
3651 // app_icon_loader1 and app_icon_loader2 are owned by 3640 // app_icon_loader1 and app_icon_loader2 are owned by
3652 // ChromeLauncherControllerImpl. 3641 // ChromeLauncherController.
3653 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); 3642 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl();
3654 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); 3643 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl();
3655 app_icon_loader1->AddSupportedApp(app_id1); 3644 app_icon_loader1->AddSupportedApp(app_id1);
3656 app_icon_loader2->AddSupportedApp(app_id2); 3645 app_icon_loader2->AddSupportedApp(app_id2);
3657 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), 3646 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1),
3658 std::unique_ptr<AppIconLoader>(app_icon_loader2)); 3647 std::unique_ptr<AppIconLoader>(app_icon_loader2));
3659 3648
3660 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( 3649 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem(
3661 base::MakeUnique<ExtensionAppWindowLauncherItemController>( 3650 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3662 ash::AppLaunchId(app_id3)), 3651 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()); 3685 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3697 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3686 EXPECT_EQ(1, app_icon_loader2->clear_count());
3698 3687
3699 launcher_controller_->CloseLauncherItem(shelfId3); 3688 launcher_controller_->CloseLauncherItem(shelfId3);
3700 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3689 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3701 EXPECT_EQ(1, app_icon_loader1->clear_count()); 3690 EXPECT_EQ(1, app_icon_loader1->clear_count());
3702 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3691 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3703 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3692 EXPECT_EQ(1, app_icon_loader2->clear_count());
3704 } 3693 }
3705 3694
3706 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) { 3695 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPinPolicy) {
3707 InitLauncherControllerWithBrowser(); 3696 InitLauncherControllerWithBrowser();
3708 arc::mojom::AppInfo appinfo = CreateAppInfo( 3697 arc::mojom::AppInfo appinfo = CreateAppInfo(
3709 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); 3698 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE);
3710 const std::string app_id = AddArcAppAndShortcut(appinfo); 3699 const std::string app_id = AddArcAppAndShortcut(appinfo);
3711 3700
3712 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app 3701 // 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 3702 // 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. 3703 // by hash we can determine that appropriate package was set by policy.
3715 base::ListValue policy_value; 3704 base::ListValue policy_value;
3716 InsertPrefValue(&policy_value, 0, appinfo.package_name); 3705 InsertPrefValue(&policy_value, 0, appinfo.package_name);
3717 profile()->GetTestingPrefService()->SetManagedPref( 3706 profile()->GetTestingPrefService()->SetManagedPref(
3718 prefs::kPolicyPinnedLauncherApps, policy_value.CreateDeepCopy()); 3707 prefs::kPolicyPinnedLauncherApps, policy_value.CreateDeepCopy());
3719 3708
3720 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 3709 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
3721 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 3710 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
3722 GetPinnableForAppID(app_id, profile())); 3711 GetPinnableForAppID(app_id, profile()));
3723 } 3712 }
3724 3713
3725 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcManaged) { 3714 TEST_P(ChromeLauncherControllerWithArcTest, ArcManaged) {
3726 // TODO(victorhsieh): Implement opt-in and opt-out. 3715 // TODO(victorhsieh): Implement opt-in and opt-out.
3727 if (arc::ShouldArcAlwaysStart()) 3716 if (arc::ShouldArcAlwaysStart())
3728 return; 3717 return;
3729 3718
3730 extension_service_->AddExtension(arc_support_host_.get()); 3719 extension_service_->AddExtension(arc_support_host_.get());
3731 // Test enables ARC, so turn it off for initial values. 3720 // Test enables ARC, so turn it off for initial values.
3732 EnablePlayStore(false); 3721 EnablePlayStore(false);
3733 3722
3734 InitLauncherController(); 3723 InitLauncherController();
3735 3724
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3777 "AppList, Chrome"); 3766 "AppList, Chrome");
3778 3767
3779 // Even if re-enable it again, Play Store pin does not appear automatically. 3768 // Even if re-enable it again, Play Store pin does not appear automatically.
3780 EnablePlayStore(true); 3769 EnablePlayStore(true);
3781 ValidateArcState(true, false, 3770 ValidateArcState(true, false,
3782 arc::ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, 3771 arc::ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE,
3783 "AppList, Chrome"); 3772 "AppList, Chrome");
3784 } 3773 }
3785 3774
3786 // Test the application menu of a shelf item with multiple ARC windows. 3775 // Test the application menu of a shelf item with multiple ARC windows.
3787 TEST_P(ChromeLauncherControllerImplWithArcTest, ShelfItemWithMultipleWindows) { 3776 TEST_P(ChromeLauncherControllerWithArcTest, ShelfItemWithMultipleWindows) {
3788 InitLauncherControllerWithBrowser(); 3777 InitLauncherControllerWithBrowser();
3789 3778
3790 arc::mojom::AppInfo appinfo = 3779 arc::mojom::AppInfo appinfo =
3791 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE); 3780 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE);
3792 AddArcAppAndShortcut(appinfo); 3781 AddArcAppAndShortcut(appinfo);
3793 3782
3794 // Widgets will be deleted by the system. 3783 // Widgets will be deleted by the system.
3795 NotifyOnTaskCreated(appinfo, 1 /* task_id */); 3784 NotifyOnTaskCreated(appinfo, 1 /* task_id */);
3796 views::Widget* window1 = CreateArcWindow("org.chromium.arc.1"); 3785 views::Widget* window1 = CreateArcWindow("org.chromium.arc.1");
3797 ASSERT_TRUE(window1); 3786 ASSERT_TRUE(window1);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3838 3827
3839 // Execute command to activate second window. 3828 // Execute command to activate second window.
3840 item_delegate->ExecuteCommand(items[0]->command_id, 0); 3829 item_delegate->ExecuteCommand(items[0]->command_id, 0);
3841 EXPECT_FALSE(window1->IsActive()); 3830 EXPECT_FALSE(window1->IsActive());
3842 EXPECT_TRUE(window2->IsActive()); 3831 EXPECT_TRUE(window2->IsActive());
3843 } 3832 }
3844 3833
3845 namespace { 3834 namespace {
3846 3835
3847 class ChromeLauncherControllerOrientationTest 3836 class ChromeLauncherControllerOrientationTest
3848 : public ChromeLauncherControllerImplWithArcTest { 3837 : public ChromeLauncherControllerWithArcTest {
3849 public: 3838 public:
3850 ChromeLauncherControllerOrientationTest() {} 3839 ChromeLauncherControllerOrientationTest() {}
3851 ~ChromeLauncherControllerOrientationTest() override {} 3840 ~ChromeLauncherControllerOrientationTest() override {}
3852 3841
3853 protected: 3842 protected:
3854 void InitApps() { 3843 void InitApps() {
3855 appinfo_none_ = 3844 appinfo_none_ =
3856 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE); 3845 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE);
3857 appinfo_landscape_ = 3846 appinfo_landscape_ =
3858 CreateAppInfo("Landscape", "Landscape", "com.example.app", 3847 CreateAppInfo("Landscape", "Landscape", "com.example.app",
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3916 3905
3917 private: 3906 private:
3918 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); 3907 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest);
3919 }; 3908 };
3920 3909
3921 INSTANTIATE_TEST_CASE_P(, 3910 INSTANTIATE_TEST_CASE_P(,
3922 ChromeLauncherControllerOrientationTest, 3911 ChromeLauncherControllerOrientationTest,
3923 ::testing::Bool()); 3912 ::testing::Bool());
3924 3913
3925 class ChromeLauncherControllerArcDefaultAppsTest 3914 class ChromeLauncherControllerArcDefaultAppsTest
3926 : public ChromeLauncherControllerImplTest, 3915 : public ChromeLauncherControllerTest,
3927 public ::testing::WithParamInterface<bool> { 3916 public ::testing::WithParamInterface<bool> {
3928 public: 3917 public:
3929 ChromeLauncherControllerArcDefaultAppsTest() {} 3918 ChromeLauncherControllerArcDefaultAppsTest() {}
3930 ~ChromeLauncherControllerArcDefaultAppsTest() override {} 3919 ~ChromeLauncherControllerArcDefaultAppsTest() override {}
3931 3920
3932 protected: 3921 protected:
3933 void SetUp() override { 3922 void SetUp() override {
3934 if (GetParam()) 3923 if (GetParam())
3935 arc::SetArcAlwaysStartForTesting(); 3924 arc::SetArcAlwaysStartForTesting();
3936 ArcDefaultAppList::UseTestAppsDirectory(); 3925 ArcDefaultAppList::UseTestAppsDirectory();
3937 ChromeLauncherControllerImplTest::SetUp(); 3926 ChromeLauncherControllerTest::SetUp();
3938 } 3927 }
3939 3928
3940 private: 3929 private:
3941 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); 3930 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest);
3942 }; 3931 };
3943 3932
3944 INSTANTIATE_TEST_CASE_P(, 3933 INSTANTIATE_TEST_CASE_P(,
3945 ChromeLauncherControllerArcDefaultAppsTest, 3934 ChromeLauncherControllerArcDefaultAppsTest,
3946 ::testing::Bool()); 3935 ::testing::Bool());
3947 3936
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
4159 launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId)); 4148 launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId));
4160 EXPECT_TRUE(item_delegate); 4149 EXPECT_TRUE(item_delegate);
4161 SelectItem(item_delegate); 4150 SelectItem(item_delegate);
4162 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); 4151 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId));
4163 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp( 4152 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(
4164 arc::kPlayStoreAppId)); 4153 arc::kPlayStoreAppId));
4165 } 4154 }
4166 4155
4167 // Checks the case when several app items have the same ordinal position (which 4156 // Checks the case when several app items have the same ordinal position (which
4168 // is valid case). 4157 // is valid case).
4169 TEST_F(ChromeLauncherControllerImplTest, CheckPositionConflict) { 4158 TEST_F(ChromeLauncherControllerTest, CheckPositionConflict) {
4170 InitLauncherController(); 4159 InitLauncherController();
4171 4160
4172 extension_service_->AddExtension(extension1_.get()); 4161 extension_service_->AddExtension(extension1_.get());
4173 extension_service_->AddExtension(extension2_.get()); 4162 extension_service_->AddExtension(extension2_.get());
4174 extension_service_->AddExtension(extension3_.get()); 4163 extension_service_->AddExtension(extension3_.get());
4175 4164
4176 syncer::SyncChangeList sync_list; 4165 syncer::SyncChangeList sync_list;
4177 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); 4166 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId);
4178 InsertAddPinChange(&sync_list, 1, extension1_->id()); 4167 InsertAddPinChange(&sync_list, 1, extension1_->id());
4179 InsertAddPinChange(&sync_list, 1, extension2_->id()); 4168 InsertAddPinChange(&sync_list, 1, extension2_->id());
(...skipping 29 matching lines...) Expand all
4209 EXPECT_TRUE( 4198 EXPECT_TRUE(
4210 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); 4199 position_1.Equals(app_service_->GetPinPosition(extension1_->id())));
4211 EXPECT_TRUE( 4200 EXPECT_TRUE(
4212 position_2.Equals(app_service_->GetPinPosition(extension2_->id()))); 4201 position_2.Equals(app_service_->GetPinPosition(extension2_->id())));
4213 EXPECT_TRUE( 4202 EXPECT_TRUE(
4214 position_3.Equals(app_service_->GetPinPosition(extension3_->id()))); 4203 position_3.Equals(app_service_->GetPinPosition(extension3_->id())));
4215 } 4204 }
4216 4205
4217 // Test the case when sync app is turned off and we need to use local copy to 4206 // Test the case when sync app is turned off and we need to use local copy to
4218 // support user's pins. 4207 // support user's pins.
4219 TEST_F(ChromeLauncherControllerImplTest, SyncOffLocalUpdate) { 4208 TEST_F(ChromeLauncherControllerTest, SyncOffLocalUpdate) {
4220 InitLauncherController(); 4209 InitLauncherController();
4221 4210
4222 extension_service_->AddExtension(extension1_.get()); 4211 extension_service_->AddExtension(extension1_.get());
4223 extension_service_->AddExtension(extension2_.get()); 4212 extension_service_->AddExtension(extension2_.get());
4224 4213
4225 syncer::SyncChangeList sync_list; 4214 syncer::SyncChangeList sync_list;
4226 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); 4215 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId);
4227 InsertAddPinChange(&sync_list, 1, extension1_->id()); 4216 InsertAddPinChange(&sync_list, 1, extension1_->id());
4228 InsertAddPinChange(&sync_list, 1, extension2_->id()); 4217 InsertAddPinChange(&sync_list, 1, extension2_->id());
4229 SendPinChanges(sync_list, true); 4218 SendPinChanges(sync_list, true);
(...skipping 10 matching lines...) Expand all
4240 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4229 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4241 launcher_controller_->UnpinAppWithID(extension2_->id()); 4230 launcher_controller_->UnpinAppWithID(extension2_->id());
4242 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 4231 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
4243 4232
4244 // Resume syncing and sync information overrides local copy. 4233 // Resume syncing and sync information overrides local copy.
4245 StartAppSyncService(copy_sync_list); 4234 StartAppSyncService(copy_sync_list);
4246 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4235 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4247 } 4236 }
4248 4237
4249 // Tests that shelf profile preferences are loaded on login. 4238 // Tests that shelf profile preferences are loaded on login.
4250 TEST_F(ChromeLauncherControllerImplTest, PrefsLoadedOnLogin) { 4239 TEST_F(ChromeLauncherControllerTest, PrefsLoadedOnLogin) {
4251 PrefService* prefs = profile()->GetTestingPrefService(); 4240 PrefService* prefs = profile()->GetTestingPrefService();
4252 prefs->SetString(prefs::kShelfAlignmentLocal, "Left"); 4241 prefs->SetString(prefs::kShelfAlignmentLocal, "Left");
4253 prefs->SetString(prefs::kShelfAlignment, "Left"); 4242 prefs->SetString(prefs::kShelfAlignment, "Left");
4254 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, "Always"); 4243 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, "Always");
4255 prefs->SetString(prefs::kShelfAutoHideBehavior, "Always"); 4244 prefs->SetString(prefs::kShelfAutoHideBehavior, "Always");
4256 4245
4257 TestChromeLauncherControllerImpl* test_launcher_controller = 4246 TestChromeLauncherController* test_launcher_controller =
4258 shell_delegate_->CreateTestLauncherController(profile()); 4247 shell_delegate_->CreateTestLauncherController(profile());
4259 4248
4260 // Simulate login for the test controller. 4249 // Simulate login for the test controller.
4261 test_launcher_controller->ReleaseProfile(); 4250 test_launcher_controller->ReleaseProfile();
4262 test_launcher_controller->AttachProfile(profile()); 4251 test_launcher_controller->AttachProfile(profile());
4263 base::RunLoop().RunUntilIdle(); 4252 base::RunLoop().RunUntilIdle();
4264 4253
4265 TestShelfController* shelf_controller = 4254 TestShelfController* shelf_controller =
4266 test_launcher_controller->test_shelf_controller(); 4255 test_launcher_controller->test_shelf_controller();
4267 ASSERT_TRUE(shelf_controller); 4256 ASSERT_TRUE(shelf_controller);
4268 EXPECT_EQ(ash::SHELF_ALIGNMENT_LEFT, shelf_controller->alignment()); 4257 EXPECT_EQ(ash::SHELF_ALIGNMENT_LEFT, shelf_controller->alignment());
4269 EXPECT_EQ(1u, shelf_controller->alignment_change_count()); 4258 EXPECT_EQ(1u, shelf_controller->alignment_change_count());
4270 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4259 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4271 shelf_controller->auto_hide()); 4260 shelf_controller->auto_hide());
4272 EXPECT_EQ(1u, shelf_controller->auto_hide_change_count()); 4261 EXPECT_EQ(1u, shelf_controller->auto_hide_change_count());
4273 } 4262 }
4274 4263
4275 // Tests that the shelf controller's changes are not wastefully echoed back. 4264 // Tests that the shelf controller's changes are not wastefully echoed back.
4276 TEST_F(ChromeLauncherControllerImplTest, DoNotEchoShelfControllerChanges) { 4265 TEST_F(ChromeLauncherControllerTest, DoNotEchoShelfControllerChanges) {
4277 TestChromeLauncherControllerImpl* test_launcher_controller = 4266 TestChromeLauncherController* test_launcher_controller =
4278 shell_delegate_->CreateTestLauncherController(profile()); 4267 shell_delegate_->CreateTestLauncherController(profile());
4279 4268
4280 // Simulate login for the test controller. 4269 // Simulate login for the test controller.
4281 test_launcher_controller->ReleaseProfile(); 4270 test_launcher_controller->ReleaseProfile();
4282 test_launcher_controller->AttachProfile(profile()); 4271 test_launcher_controller->AttachProfile(profile());
4283 base::RunLoop().RunUntilIdle(); 4272 base::RunLoop().RunUntilIdle();
4284 4273
4285 TestShelfController* shelf_controller = 4274 TestShelfController* shelf_controller =
4286 test_launcher_controller->test_shelf_controller(); 4275 test_launcher_controller->test_shelf_controller();
4287 ASSERT_TRUE(shelf_controller); 4276 ASSERT_TRUE(shelf_controller);
(...skipping 18 matching lines...) Expand all
4306 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4295 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4307 shelf_controller->auto_hide()); 4296 shelf_controller->auto_hide());
4308 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4297 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4309 4298
4310 PrefService* prefs = profile()->GetTestingPrefService(); 4299 PrefService* prefs = profile()->GetTestingPrefService();
4311 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4300 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4312 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4301 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4313 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4302 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4314 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4303 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4315 } 4304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698