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

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

Issue 2791803002: mash: Move LauncherItemController to ash, rename ShelfItemDelegate. (Closed)
Patch Set: Sync and rebase. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 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_impl.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>
16 16
17 #include "ash/common/shelf/shelf_application_menu_model.h" 17 #include "ash/common/shelf/shelf_application_menu_model.h"
18 #include "ash/common/shelf/shelf_constants.h" 18 #include "ash/common/shelf/shelf_constants.h"
19 #include "ash/common/shelf/shelf_controller.h" 19 #include "ash/common/shelf/shelf_controller.h"
20 #include "ash/common/shelf/shelf_model.h" 20 #include "ash/common/shelf/shelf_model.h"
21 #include "ash/common/shelf/shelf_model_observer.h" 21 #include "ash/common/shelf/shelf_model_observer.h"
22 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 22 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
23 #include "ash/common/wm_shell.h" 23 #include "ash/common/wm_shell.h"
24 #include "ash/display/screen_orientation_controller_chromeos.h" 24 #include "ash/display/screen_orientation_controller_chromeos.h"
25 #include "ash/public/cpp/app_launch_id.h" 25 #include "ash/public/cpp/app_launch_id.h"
26 #include "ash/public/cpp/shelf_item.h" 26 #include "ash/public/cpp/shelf_item.h"
27 #include "ash/public/cpp/shelf_item_delegate.h"
27 #include "ash/shell.h" 28 #include "ash/shell.h"
28 #include "ash/test/ash_test_helper.h" 29 #include "ash/test/ash_test_helper.h"
29 #include "ash/test/shell_test_api.h" 30 #include "ash/test/shell_test_api.h"
30 #include "ash/test/test_shell_delegate.h" 31 #include "ash/test/test_shell_delegate.h"
31 #include "ash/wm/window_util.h" 32 #include "ash/wm/window_util.h"
32 #include "base/command_line.h" 33 #include "base/command_line.h"
33 #include "base/compiler_specific.h" 34 #include "base/compiler_specific.h"
34 #include "base/files/file_path.h" 35 #include "base/files/file_path.h"
35 #include "base/json/json_string_value_serializer.h" 36 #include "base/json/json_string_value_serializer.h"
36 #include "base/location.h" 37 #include "base/location.h"
(...skipping 19 matching lines...) Expand all
56 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 57 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
57 #include "chrome/browser/ui/app_list/arc/arc_default_app_list.h" 58 #include "chrome/browser/ui/app_list/arc/arc_default_app_list.h"
58 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 59 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
59 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 60 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
60 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" 61 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h"
61 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 62 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
62 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" 63 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
63 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" 64 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
64 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont roller.h" 65 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont roller.h"
65 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 66 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
66 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
67 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 67 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
68 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 68 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
69 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" 69 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
70 #include "chrome/browser/ui/browser.h" 70 #include "chrome/browser/ui/browser.h"
71 #include "chrome/browser/ui/browser_commands.h" 71 #include "chrome/browser/ui/browser_commands.h"
72 #include "chrome/browser/ui/browser_finder.h" 72 #include "chrome/browser/ui/browser_finder.h"
73 #include "chrome/browser/ui/browser_list.h" 73 #include "chrome/browser/ui/browser_list.h"
74 #include "chrome/browser/ui/browser_tabstrip.h" 74 #include "chrome/browser/ui/browser_tabstrip.h"
75 #include "chrome/browser/ui/tabs/tab_strip_model.h" 75 #include "chrome/browser/ui/tabs/tab_strip_model.h"
76 #include "chrome/common/chrome_constants.h" 76 #include "chrome/common/chrome_constants.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override { 154 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override {
155 ++changed_; 155 ++changed_;
156 last_index_ = index; 156 last_index_ = index;
157 } 157 }
158 158
159 void ShelfItemMoved(int start_index, int target_index) override { 159 void ShelfItemMoved(int start_index, int target_index) override {
160 last_index_ = target_index; 160 last_index_ = target_index;
161 } 161 }
162 162
163 void OnSetShelfItemDelegate( 163 void OnSetShelfItemDelegate(ash::ShelfID id,
164 ash::ShelfID id, 164 ash::ShelfItemDelegate* item_delegate) override {}
165 ash::mojom::ShelfItemDelegate* item_delegate) override {}
166 165
167 void clear_counts() { 166 void clear_counts() {
168 added_ = 0; 167 added_ = 0;
169 removed_ = 0; 168 removed_ = 0;
170 changed_ = 0; 169 changed_ = 0;
171 last_index_ = 0; 170 last_index_ = 0;
172 } 171 }
173 172
174 int added() const { return added_; } 173 int added() const { return added_; }
175 int removed() const { return removed_; } 174 int removed() const { return removed_; }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 248
250 private: 249 private:
251 typedef std::map<content::WebContents*, std::string> TabToStringMap; 250 typedef std::map<content::WebContents*, std::string> TabToStringMap;
252 251
253 TabToStringMap tab_id_map_; 252 TabToStringMap tab_id_map_;
254 253
255 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper); 254 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper);
256 }; 255 };
257 256
258 // Test implementation of a V2 app launcher item controller. 257 // Test implementation of a V2 app launcher item controller.
259 class TestV2AppLauncherItemController : public LauncherItemController { 258 class TestV2AppLauncherItemController : public ash::ShelfItemDelegate {
260 public: 259 public:
261 TestV2AppLauncherItemController(const std::string& app_id, 260 explicit TestV2AppLauncherItemController(const std::string& app_id)
262 ChromeLauncherController* controller) 261 : ash::ShelfItemDelegate(ash::AppLaunchId(app_id)) {}
263 : LauncherItemController(ash::AppLaunchId(app_id), controller) {}
264 262
265 ~TestV2AppLauncherItemController() override {} 263 ~TestV2AppLauncherItemController() override {}
266 264
267 // Override for LauncherItemController: 265 // Override for ash::ShelfItemDelegate:
268 void ItemSelected(std::unique_ptr<ui::Event> event, 266 void ItemSelected(std::unique_ptr<ui::Event> event,
269 int64_t display_id, 267 int64_t display_id,
270 ash::ShelfLaunchSource source, 268 ash::ShelfLaunchSource source,
271 const ItemSelectedCallback& callback) override { 269 const ItemSelectedCallback& callback) override {
272 callback.Run(ash::SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt); 270 callback.Run(ash::SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt);
273 } 271 }
274 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override {} 272 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override {}
275 void Close() override {} 273 void Close() override {}
276 274
277 private: 275 private:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return controller_->UnpinAppWithID(app_id); 312 return controller_->UnpinAppWithID(app_id);
315 } 313 }
316 314
317 private: 315 private:
318 ChromeLauncherControllerImpl* const controller_; 316 ChromeLauncherControllerImpl* const controller_;
319 317
320 DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate); 318 DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate);
321 }; 319 };
322 320
323 // A callback that does nothing after shelf item selection handling. 321 // A callback that does nothing after shelf item selection handling.
324 void NoopCallback(ash::ShelfAction action, base::Optional<MenuItemList>) {} 322 void NoopCallback(ash::ShelfAction action, base::Optional<ash::MenuItemList>) {}
325 323
326 // Simulates selection of the shelf item. 324 // Simulates selection of the shelf item.
327 void SelectItem(ash::mojom::ShelfItemDelegate* delegate) { 325 void SelectItem(ash::ShelfItemDelegate* delegate) {
328 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::MouseEvent>( 326 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::MouseEvent>(
329 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), 327 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
330 ui::EF_NONE, 0); 328 ui::EF_NONE, 0);
331 delegate->ItemSelected(std::move(event), display::kInvalidDisplayId, 329 delegate->ItemSelected(std::move(event), display::kInvalidDisplayId,
332 ash::LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback)); 330 ash::LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback));
333 } 331 }
334 332
335 } // namespace 333 } // namespace
336 334
337 class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest { 335 class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, 446 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
449 manifest, Extension::NO_FLAGS, 447 manifest, Extension::NO_FLAGS,
450 ArcSupportHost::kHostAppId, &error); 448 ArcSupportHost::kHostAppId, &error);
451 extension_service_->AddExtension(extension_chrome_.get()); 449 extension_service_->AddExtension(extension_chrome_.get());
452 } 450 }
453 451
454 // Creates a running platform V2 app (not pinned) of type |app_id|. 452 // Creates a running platform V2 app (not pinned) of type |app_id|.
455 virtual void CreateRunningV2App(const std::string& app_id) { 453 virtual void CreateRunningV2App(const std::string& app_id) {
456 DCHECK(!test_controller_); 454 DCHECK(!test_controller_);
457 // Change the created launcher controller into a V2 app controller. 455 // Change the created launcher controller into a V2 app controller.
458 test_controller_ = new TestV2AppLauncherItemController(app_id, 456 std::unique_ptr<TestV2AppLauncherItemController> controller =
459 launcher_controller_.get()); 457 base::MakeUnique<TestV2AppLauncherItemController>(app_id);
458 test_controller_ = controller.get();
460 ash::ShelfID id = launcher_controller_->InsertAppLauncherItem( 459 ash::ShelfID id = launcher_controller_->InsertAppLauncherItem(
461 test_controller_, ash::STATUS_RUNNING, model_->item_count(), 460 std::move(controller), ash::STATUS_RUNNING, model_->item_count(),
462 ash::TYPE_APP); 461 ash::TYPE_APP);
463 DCHECK(launcher_controller_->IsPlatformApp(id)); 462 DCHECK(launcher_controller_->IsPlatformApp(id));
464 } 463 }
465 464
466 // Sets the stage for a multi user test. 465 // Sets the stage for a multi user test.
467 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, 466 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a,
468 syncer::SyncChangeList* user_b) { 467 syncer::SyncChangeList* user_b) {
469 InitLauncherController(); 468 InitLauncherController();
470 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 469 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
471 470
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 scoped_refptr<Extension> arc_support_host_; 969 scoped_refptr<Extension> arc_support_host_;
971 970
972 ArcAppTest arc_test_; 971 ArcAppTest arc_test_;
973 bool auto_start_arc_test_ = false; 972 bool auto_start_arc_test_ = false;
974 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; 973 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_;
975 std::unique_ptr<TestShelfModelObserver> model_observer_; 974 std::unique_ptr<TestShelfModelObserver> model_observer_;
976 ash::ShelfModel* model_ = nullptr; 975 ash::ShelfModel* model_ = nullptr;
977 std::unique_ptr<TestingProfileManager> profile_manager_; 976 std::unique_ptr<TestingProfileManager> profile_manager_;
978 977
979 // |item_delegate_manager_| owns |test_controller_|. 978 // |item_delegate_manager_| owns |test_controller_|.
980 LauncherItemController* test_controller_ = nullptr; 979 ash::ShelfItemDelegate* test_controller_ = nullptr;
981 980
982 ExtensionService* extension_service_ = nullptr; 981 ExtensionService* extension_service_ = nullptr;
983 982
984 app_list::AppListSyncableService* app_service_ = nullptr; 983 app_list::AppListSyncableService* app_service_ = nullptr;
985 984
986 private: 985 private:
987 TestBrowserWindow* CreateTestBrowserWindowAura() { 986 TestBrowserWindow* CreateTestBrowserWindowAura() {
988 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); 987 std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
989 window->set_id(0); 988 window->set_id(0);
990 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 989 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 1040
1042 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 1041 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
1043 1042
1044 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); 1043 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher);
1045 }; 1044 };
1046 1045
1047 // A V1 windowed application. 1046 // A V1 windowed application.
1048 class V1App : public TestBrowserWindow { 1047 class V1App : public TestBrowserWindow {
1049 public: 1048 public:
1050 V1App(Profile* profile, const std::string& app_name) { 1049 V1App(Profile* profile, const std::string& app_name) {
1051 // Create a window.
1052 native_window_.reset(new aura::Window(NULL));
1053 native_window_->set_id(0);
1054 native_window_->SetType(ui::wm::WINDOW_TYPE_POPUP);
1055 native_window_->Init(ui::LAYER_TEXTURED);
1056 native_window_->Show();
1057 aura::client::ParentWindowWithContext(native_window_.get(),
1058 ash::Shell::GetPrimaryRootWindow(),
1059 gfx::Rect(10, 10, 20, 30));
1060 Browser::CreateParams params = Browser::CreateParams::CreateForApp( 1050 Browser::CreateParams params = Browser::CreateParams::CreateForApp(
1061 kCrxAppPrefix + app_name, true /* trusted_source */, gfx::Rect(), 1051 kCrxAppPrefix + app_name, true /* trusted_source */, gfx::Rect(),
1062 profile, true); 1052 profile, true);
1063 params.window = this; 1053 params.window = this;
1064 browser_.reset(new Browser(params)); 1054 browser_.reset(new Browser(params));
1065 chrome::AddTabAt(browser_.get(), GURL(), 0, true); 1055 chrome::AddTabAt(browser_.get(), GURL(), 0, true);
1066 } 1056 }
1067 1057
1068 ~V1App() override { 1058 ~V1App() override {
1069 // close all tabs. Note that we do not need to destroy the browser itself. 1059 // close all tabs. Note that we do not need to destroy the browser itself.
1070 browser_->tab_strip_model()->CloseAllTabs(); 1060 browser_->tab_strip_model()->CloseAllTabs();
1071 } 1061 }
1072 1062
1073 Browser* browser() { return browser_.get(); } 1063 Browser* browser() { return browser_.get(); }
1074 1064
1075 // TestBrowserWindow override:
1076 gfx::NativeWindow GetNativeWindow() const override {
1077 return native_window_.get();
1078 }
1079
1080 private: 1065 private:
1081 // The associated browser with this app. 1066 // The associated browser with this app.
1082 std::unique_ptr<Browser> browser_; 1067 std::unique_ptr<Browser> browser_;
1083 1068
1084 // The native window we use.
1085 std::unique_ptr<aura::Window> native_window_;
1086
1087 DISALLOW_COPY_AND_ASSIGN(V1App); 1069 DISALLOW_COPY_AND_ASSIGN(V1App);
1088 }; 1070 };
1089 1071
1090 // A V2 application window created with an |extension| and for a |profile|. 1072 // A V2 application window created with an |extension| and for a |profile|.
1091 // Upon destruction it will properly close the application; supports panels too. 1073 // Upon destruction it will properly close the application; supports panels too.
1092 class V2App { 1074 class V2App {
1093 public: 1075 public:
1094 V2App(Profile* profile, 1076 V2App(Profile* profile,
1095 const extensions::Extension* extension, 1077 const extensions::Extension* extension,
1096 extensions::AppWindow::WindowType window_type = 1078 extensions::AppWindow::WindowType window_type =
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 return browser; 1216 return browser;
1235 } 1217 }
1236 1218
1237 // Creates a running V1 application. 1219 // Creates a running V1 application.
1238 // Note that with the use of the launcher_controller_helper as done below, 1220 // Note that with the use of the launcher_controller_helper as done below,
1239 // this is only usable with a single v1 application. 1221 // this is only usable with a single v1 application.
1240 V1App* CreateRunningV1App(Profile* profile, 1222 V1App* CreateRunningV1App(Profile* profile,
1241 const std::string& app_name, 1223 const std::string& app_name,
1242 const std::string& url) { 1224 const std::string& url) {
1243 V1App* v1_app = new V1App(profile, app_name); 1225 V1App* v1_app = new V1App(profile, app_name);
1244 // Create a new launcher controller helper and assign it to the launcher so
1245 // that this app gets properly detected.
1246 // TODO(skuhne): Create a more intelligent launcher controller helper that
1247 // is able to detect all running apps properly.
1248 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper;
1249 helper->SetAppID(v1_app->browser()->tab_strip_model()->GetWebContentsAt(0),
1250 app_name);
1251 SetLauncherControllerHelper(helper);
1252
1253 NavigateAndCommitActiveTabWithTitle(v1_app->browser(), GURL(url), 1226 NavigateAndCommitActiveTabWithTitle(v1_app->browser(), GURL(url),
1254 base::string16()); 1227 base::string16());
1255 return v1_app; 1228 return v1_app;
1256 } 1229 }
1257 1230
1258 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; } 1231 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; }
1259 1232
1260 // Override BrowserWithTestWindowTest: 1233 // Override BrowserWithTestWindowTest:
1261 TestingProfile* CreateProfile() override { 1234 TestingProfile* CreateProfile() override {
1262 return CreateMultiUserProfile("user1"); 1235 return CreateMultiUserProfile("user1");
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 const ash::ShelfID shelf_id_app_2 = 1882 const ash::ShelfID shelf_id_app_2 =
1910 launcher_controller_->GetShelfIDForAppID(arc_app_id2); 1883 launcher_controller_->GetShelfIDForAppID(arc_app_id2);
1911 const ash::ShelfID shelf_id_app_3 = 1884 const ash::ShelfID shelf_id_app_3 =
1912 launcher_controller_->GetShelfIDForAppID(arc_app_id3); 1885 launcher_controller_->GetShelfIDForAppID(arc_app_id3);
1913 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); 1886 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1);
1914 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); 1887 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2);
1915 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); 1888 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3);
1916 1889
1917 // We activated arc_app_id1 twice but expect one close for item controller 1890 // We activated arc_app_id1 twice but expect one close for item controller
1918 // stops launching request. 1891 // stops launching request.
1919 LauncherItemController* item_controller = 1892 ash::ShelfItemDelegate* item_delegate =
1920 launcher_controller_->GetLauncherItemController(shelf_id_app_1); 1893 launcher_controller_->GetShelfItemDelegate(shelf_id_app_1);
1921 ASSERT_NE(nullptr, item_controller); 1894 ASSERT_NE(nullptr, item_delegate);
1922 item_controller->Close(); 1895 item_delegate->Close();
1923 base::RunLoop().RunUntilIdle(); 1896 base::RunLoop().RunUntilIdle();
1924 1897
1925 EXPECT_EQ(ash::kInvalidShelfID, 1898 EXPECT_EQ(ash::kInvalidShelfID,
1926 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1899 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1927 EXPECT_EQ(shelf_id_app_2, 1900 EXPECT_EQ(shelf_id_app_2,
1928 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1901 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1929 EXPECT_EQ(shelf_id_app_3, 1902 EXPECT_EQ(shelf_id_app_3,
1930 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 1903 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1931 1904
1932 arc_test_.RestartArcInstance(); 1905 arc_test_.RestartArcInstance();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 EXPECT_NE(ash::kInvalidShelfID, shelf_id); 1942 EXPECT_NE(ash::kInvalidShelfID, shelf_id);
1970 1943
1971 int item_index = model_->ItemIndexByID(shelf_id); 1944 int item_index = model_->ItemIndexByID(shelf_id);
1972 ASSERT_GE(item_index, 0); 1945 ASSERT_GE(item_index, 0);
1973 1946
1974 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); 1947 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED);
1975 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP); 1948 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP);
1976 1949
1977 // Play Store app is ARC app that might be represented by native Chrome 1950 // Play Store app is ARC app that might be represented by native Chrome
1978 // platform app. 1951 // platform app.
1979 AppWindowLauncherItemController* app_controller = 1952 launcher_controller_->SetShelfItemDelegate(
1980 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id), 1953 shelf_id, base::MakeUnique<ExtensionAppWindowLauncherItemController>(
1981 launcher_controller_.get()); 1954 ash::AppLaunchId(app_id)));
1982 launcher_controller_->SetItemController(shelf_id, app_controller);
1983 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 1955 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
1984 1956
1985 // This launch request should be ignored in case of active app. 1957 // This launch request should be ignored in case of active app.
1986 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); 1958 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
1987 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 1959 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
1988 1960
1989 // Close app but shortcut should exist. 1961 // Close app but shortcut should exist.
1990 launcher_controller_->CloseLauncherItem(shelf_id); 1962 launcher_controller_->CloseLauncherItem(shelf_id);
1991 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(app_id)); 1963 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(app_id));
1992 1964
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", 2259 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
2288 GetPinnedAppStatus()); 2260 GetPinnedAppStatus());
2289 } 2261 }
2290 2262
2291 // Check that with multi profile V1 apps are properly added / removed from the 2263 // Check that with multi profile V1 apps are properly added / removed from the
2292 // shelf. 2264 // shelf.
2293 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2265 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2294 V1AppUpdateOnUserSwitch) { 2266 V1AppUpdateOnUserSwitch) {
2295 // Create a browser item in the LauncherController. 2267 // Create a browser item in the LauncherController.
2296 InitLauncherController(); 2268 InitLauncherController();
2297 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2298 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
2299 2269
2300 EXPECT_EQ(2, model_->item_count()); 2270 EXPECT_EQ(2, model_->item_count());
2301 { 2271 {
2302 // Create a "windowed gmail app". 2272 // Create a "windowed gmail app".
2303 std::unique_ptr<V1App> v1_app( 2273 std::unique_ptr<V1App> v1_app(
2304 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); 2274 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url));
2305 EXPECT_EQ(3, model_->item_count()); 2275 EXPECT_EQ(3, model_->item_count());
2306 2276
2307 // After switching to a second user the item should be gone. 2277 // After switching to a second user the item should be gone.
2308 std::string user2 = "user2"; 2278 std::string user2 = "user2";
(...skipping 11 matching lines...) Expand all
2320 // Note we destroy now the gmail app with the closure end. 2290 // Note we destroy now the gmail app with the closure end.
2321 } 2291 }
2322 EXPECT_EQ(2, model_->item_count()); 2292 EXPECT_EQ(2, model_->item_count());
2323 } 2293 }
2324 2294
2325 // Check edge cases with multi profile V1 apps in the shelf. 2295 // Check edge cases with multi profile V1 apps in the shelf.
2326 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2296 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2327 V1AppUpdateOnUserSwitchEdgecases) { 2297 V1AppUpdateOnUserSwitchEdgecases) {
2328 // Create a browser item in the LauncherController. 2298 // Create a browser item in the LauncherController.
2329 InitLauncherController(); 2299 InitLauncherController();
2330 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2331 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
2332 2300
2333 // First test: Create an app when the user is not active. 2301 // First test: Create an app when the user is not active.
2334 std::string user2 = "user2"; 2302 std::string user2 = "user2";
2335 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2303 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2336 const AccountId account_id2( 2304 const AccountId account_id2(
2337 multi_user_util::GetAccountIdFromProfile(profile2)); 2305 multi_user_util::GetAccountIdFromProfile(profile2));
2338 const AccountId account_id( 2306 const AccountId account_id(
2339 multi_user_util::GetAccountIdFromProfile(profile())); 2307 multi_user_util::GetAccountIdFromProfile(profile()));
2340 { 2308 {
2341 // Create a "windowed gmail app". 2309 // Create a "windowed gmail app".
(...skipping 16 matching lines...) Expand all
2358 EXPECT_EQ(2, model_->item_count()); 2326 EXPECT_EQ(2, model_->item_count());
2359 SwitchActiveUser(account_id); 2327 SwitchActiveUser(account_id);
2360 EXPECT_EQ(2, model_->item_count()); 2328 EXPECT_EQ(2, model_->item_count());
2361 } 2329 }
2362 2330
2363 // Check edge case where a visiting V1 app gets closed (crbug.com/321374). 2331 // Check edge case where a visiting V1 app gets closed (crbug.com/321374).
2364 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2332 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2365 V1CloseOnVisitingDesktop) { 2333 V1CloseOnVisitingDesktop) {
2366 // Create a browser item in the LauncherController. 2334 // Create a browser item in the LauncherController.
2367 InitLauncherController(); 2335 InitLauncherController();
2368 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2369 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
2370 2336
2371 chrome::MultiUserWindowManager* manager = 2337 chrome::MultiUserWindowManager* manager =
2372 chrome::MultiUserWindowManager::GetInstance(); 2338 chrome::MultiUserWindowManager::GetInstance();
2373 2339
2374 // First create an app when the user is active. 2340 // First create an app when the user is active.
2375 std::string user2 = "user2"; 2341 std::string user2 = "user2";
2376 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2342 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2377 const AccountId account_id( 2343 const AccountId account_id(
2378 multi_user_util::GetAccountIdFromProfile(profile())); 2344 multi_user_util::GetAccountIdFromProfile(profile()));
2379 const AccountId account_id2( 2345 const AccountId account_id2(
(...skipping 24 matching lines...) Expand all
2404 } 2370 }
2405 SwitchActiveUser(account_id2); 2371 SwitchActiveUser(account_id2);
2406 EXPECT_EQ(2, model_->item_count()); 2372 EXPECT_EQ(2, model_->item_count());
2407 } 2373 }
2408 2374
2409 // Check edge cases with multi profile V1 apps in the shelf. 2375 // Check edge cases with multi profile V1 apps in the shelf.
2410 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2376 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2411 V1AppUpdateOnUserSwitchEdgecases2) { 2377 V1AppUpdateOnUserSwitchEdgecases2) {
2412 // Create a browser item in the LauncherController. 2378 // Create a browser item in the LauncherController.
2413 InitLauncherController(); 2379 InitLauncherController();
2414 // TODO(crbug.com/654622): This test breaks with a non-null static instance.
2415 ChromeLauncherControllerImpl::set_instance_for_test(nullptr);
2416
2417 SetLauncherControllerHelper(new TestLauncherControllerHelper);
2418 2380
2419 // First test: Create an app when the user is not active. 2381 // First test: Create an app when the user is not active.
2420 std::string user2 = "user2"; 2382 std::string user2 = "user2";
2421 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2383 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2422 const AccountId account_id( 2384 const AccountId account_id(
2423 multi_user_util::GetAccountIdFromProfile(profile())); 2385 multi_user_util::GetAccountIdFromProfile(profile()));
2424 const AccountId account_id2( 2386 const AccountId account_id2(
2425 multi_user_util::GetAccountIdFromProfile(profile2)); 2387 multi_user_util::GetAccountIdFromProfile(profile2));
2426 SwitchActiveUser(account_id2); 2388 SwitchActiveUser(account_id2);
2427 { 2389 {
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); 2833 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id());
2872 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); 2834 GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
2873 EXPECT_EQ(expected_launchers, actual_launchers); 2835 EXPECT_EQ(expected_launchers, actual_launchers);
2874 } 2836 }
2875 2837
2876 // Ensure |controller| creates the expected menu items for the given shelf item. 2838 // Ensure |controller| creates the expected menu items for the given shelf item.
2877 void CheckAppMenu(ChromeLauncherControllerImpl* controller, 2839 void CheckAppMenu(ChromeLauncherControllerImpl* controller,
2878 const ash::ShelfItem& item, 2840 const ash::ShelfItem& item,
2879 size_t expected_item_count, 2841 size_t expected_item_count,
2880 base::string16 expected_item_titles[]) { 2842 base::string16 expected_item_titles[]) {
2881 MenuItemList items = controller->GetAppMenuItemsForTesting(item); 2843 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item);
2882 ASSERT_EQ(expected_item_count, items.size()); 2844 ASSERT_EQ(expected_item_count, items.size());
2883 for (size_t i = 0; i < expected_item_count; i++) 2845 for (size_t i = 0; i < expected_item_count; i++)
2884 EXPECT_EQ(expected_item_titles[i], items[i]->label); 2846 EXPECT_EQ(expected_item_titles[i], items[i]->label);
2885 } 2847 }
2886 2848
2887 // Check that browsers get reflected correctly in the launcher menu. 2849 // Check that browsers get reflected correctly in the launcher menu.
2888 TEST_F(ChromeLauncherControllerImplTest, BrowserMenuGeneration) { 2850 TEST_F(ChromeLauncherControllerImplTest, BrowserMenuGeneration) {
2889 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 2851 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
2890 chrome::NewTab(browser()); 2852 chrome::NewTab(browser());
2891 2853
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
3322 chrome::NewTab(browser()); 3284 chrome::NewTab(browser());
3323 base::string16 title2 = ASCIIToUTF16("Test2"); 3285 base::string16 title2 = ASCIIToUTF16("Test2");
3324 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); 3286 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2);
3325 3287
3326 // Check that the menu is properly set. 3288 // Check that the menu is properly set.
3327 ash::ShelfItem item_gmail; 3289 ash::ShelfItem item_gmail;
3328 item_gmail.type = ash::TYPE_PINNED_APP; 3290 item_gmail.type = ash::TYPE_PINNED_APP;
3329 item_gmail.id = gmail_id; 3291 item_gmail.id = gmail_id;
3330 base::string16 two_menu_items[] = {title1, title2}; 3292 base::string16 two_menu_items[] = {title1, title2};
3331 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items); 3293 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items);
3332 LauncherItemController* item_controller = 3294 ash::ShelfItemDelegate* item_delegate =
3333 launcher_controller_->GetLauncherItemController(gmail_id); 3295 launcher_controller_->GetShelfItemDelegate(gmail_id);
3334 ASSERT_TRUE(item_controller); 3296 ASSERT_TRUE(item_delegate);
3335 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 3297 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
3336 // Execute the second item in the menu, after the title and two separators, 3298 // Execute the second item in the menu, after the title and two separators,
3337 // this shouldn't do anything since that item is already the active tab. 3299 // this shouldn't do anything since that item is already the active tab.
3338 { 3300 {
3339 ash::ShelfApplicationMenuModel menu( 3301 ash::ShelfApplicationMenuModel menu(
3340 base::string16(), 3302 base::string16(),
3341 launcher_controller_->GetAppMenuItemsForTesting(item_gmail), 3303 launcher_controller_->GetAppMenuItemsForTesting(item_gmail),
3342 item_controller); 3304 item_delegate);
3343 menu.ActivatedAt(4); 3305 menu.ActivatedAt(4);
3344 } 3306 }
3345 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 3307 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
3346 3308
3347 // Execute the first item in the menu, after the title and two separators, 3309 // Execute the first item in the menu, after the title and two separators,
3348 // this should activate the other tab. 3310 // this should activate the other tab.
3349 { 3311 {
3350 ash::ShelfApplicationMenuModel menu( 3312 ash::ShelfApplicationMenuModel menu(
3351 base::string16(), 3313 base::string16(),
3352 launcher_controller_->GetAppMenuItemsForTesting(item_gmail), 3314 launcher_controller_->GetAppMenuItemsForTesting(item_gmail),
3353 item_controller); 3315 item_delegate);
3354 menu.ActivatedAt(3); 3316 menu.ActivatedAt(3);
3355 } 3317 }
3356 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 3318 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
3357 } 3319 }
3358 3320
3359 // Checks that the generated menu list properly deletes items. 3321 // Checks that the generated menu list properly deletes items.
3360 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuDeletionExecution) { 3322 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuDeletionExecution) {
3361 InitLauncherControllerWithBrowser(); 3323 InitLauncherControllerWithBrowser();
3362 3324
3363 // Add |extension3_| to the launcher and add two items. 3325 // Add |extension3_| to the launcher and add two items.
3364 GURL gmail = GURL("https://mail.google.com/mail/u"); 3326 GURL gmail = GURL("https://mail.google.com/mail/u");
3365 ash::ShelfID gmail_id = model_->next_id(); 3327 ash::ShelfID gmail_id = model_->next_id();
3366 extension_service_->AddExtension(extension3_.get()); 3328 extension_service_->AddExtension(extension3_.get());
3367 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3329 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3368 base::string16 title1 = ASCIIToUTF16("Test1"); 3330 base::string16 title1 = ASCIIToUTF16("Test1");
3369 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3331 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3370 chrome::NewTab(browser()); 3332 chrome::NewTab(browser());
3371 base::string16 title2 = ASCIIToUTF16("Test2"); 3333 base::string16 title2 = ASCIIToUTF16("Test2");
3372 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); 3334 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2);
3373 3335
3374 // Check that the menu is properly set. 3336 // Check that the menu is properly set.
3375 ash::ShelfItem item_gmail; 3337 ash::ShelfItem item_gmail;
3376 item_gmail.type = ash::TYPE_PINNED_APP; 3338 item_gmail.type = ash::TYPE_PINNED_APP;
3377 item_gmail.id = gmail_id; 3339 item_gmail.id = gmail_id;
3378 base::string16 two_menu_items[] = {title1, title2}; 3340 base::string16 two_menu_items[] = {title1, title2};
3379 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items); 3341 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items);
3380 3342
3381 LauncherItemController* item_controller = 3343 ash::ShelfItemDelegate* item_delegate =
3382 launcher_controller_->GetLauncherItemController(gmail_id); 3344 launcher_controller_->GetShelfItemDelegate(gmail_id);
3383 ASSERT_TRUE(item_controller); 3345 ASSERT_TRUE(item_delegate);
3384 int tabs = browser()->tab_strip_model()->count(); 3346 int tabs = browser()->tab_strip_model()->count();
3385 // Activate the proper tab through the menu item. 3347 // Activate the proper tab through the menu item.
3386 { 3348 {
3387 MenuItemList items = 3349 ash::MenuItemList items =
3388 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); 3350 launcher_controller_->GetAppMenuItemsForTesting(item_gmail);
3389 item_controller->ExecuteCommand(items[1]->command_id, ui::EF_NONE); 3351 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_NONE);
3390 EXPECT_EQ(tabs, browser()->tab_strip_model()->count()); 3352 EXPECT_EQ(tabs, browser()->tab_strip_model()->count());
3391 } 3353 }
3392 3354
3393 // Delete one tab through the menu item. 3355 // Delete one tab through the menu item.
3394 { 3356 {
3395 MenuItemList items = 3357 ash::MenuItemList items =
3396 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); 3358 launcher_controller_->GetAppMenuItemsForTesting(item_gmail);
3397 item_controller->ExecuteCommand(items[1]->command_id, ui::EF_SHIFT_DOWN); 3359 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_SHIFT_DOWN);
3398 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); 3360 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count());
3399 } 3361 }
3400 } 3362 }
3401 3363
3402 // Tests that panels create launcher items correctly 3364 // Tests that panels create launcher items correctly
3403 TEST_F(ChromeLauncherControllerImplTest, AppPanels) { 3365 TEST_F(ChromeLauncherControllerImplTest, AppPanels) {
3404 InitLauncherController(); 3366 InitLauncherController();
3405 model_observer_->clear_counts(); 3367 model_observer_->clear_counts();
3406 const std::string app_id = extension1_->id(); 3368 const std::string app_id = extension1_->id();
3407 3369
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3617 const std::string app_id3 = extension3_->id(); 3579 const std::string app_id3 = extension3_->id();
3618 // app_icon_loader1 and app_icon_loader2 are owned by 3580 // app_icon_loader1 and app_icon_loader2 are owned by
3619 // ChromeLauncherControllerImpl. 3581 // ChromeLauncherControllerImpl.
3620 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); 3582 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl();
3621 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); 3583 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl();
3622 app_icon_loader1->AddSupportedApp(app_id1); 3584 app_icon_loader1->AddSupportedApp(app_id1);
3623 app_icon_loader2->AddSupportedApp(app_id2); 3585 app_icon_loader2->AddSupportedApp(app_id2);
3624 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), 3586 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1),
3625 std::unique_ptr<AppIconLoader>(app_icon_loader2)); 3587 std::unique_ptr<AppIconLoader>(app_icon_loader2));
3626 3588
3627 AppWindowLauncherItemController* app_controller3 =
3628 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id3),
3629 launcher_controller_.get());
3630 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( 3589 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem(
3631 app_controller3, ash::STATUS_RUNNING); 3590 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3591 ash::AppLaunchId(app_id3)),
3592 ash::STATUS_RUNNING);
3632 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3593 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3633 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3594 EXPECT_EQ(0, app_icon_loader1->clear_count());
3634 EXPECT_EQ(0, app_icon_loader2->fetch_count()); 3595 EXPECT_EQ(0, app_icon_loader2->fetch_count());
3635 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3596 EXPECT_EQ(0, app_icon_loader2->clear_count());
3636 3597
3637 AppWindowLauncherItemController* app_controller2 =
3638 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id2),
3639 launcher_controller_.get());
3640 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( 3598 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem(
3641 app_controller2, ash::STATUS_RUNNING); 3599 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3600 ash::AppLaunchId(app_id2)),
3601 ash::STATUS_RUNNING);
3642 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3602 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3643 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3603 EXPECT_EQ(0, app_icon_loader1->clear_count());
3644 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3604 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3645 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3605 EXPECT_EQ(0, app_icon_loader2->clear_count());
3646 3606
3647 AppWindowLauncherItemController* app_controller1 =
3648 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id1),
3649 launcher_controller_.get());
3650
3651 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( 3607 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem(
3652 app_controller1, ash::STATUS_RUNNING); 3608 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3609 ash::AppLaunchId(app_id1)),
3610 ash::STATUS_RUNNING);
3653 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3611 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3654 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3612 EXPECT_EQ(0, app_icon_loader1->clear_count());
3655 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3613 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3656 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3614 EXPECT_EQ(0, app_icon_loader2->clear_count());
3657 3615
3658 launcher_controller_->CloseLauncherItem(shelfId1); 3616 launcher_controller_->CloseLauncherItem(shelfId1);
3659 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3617 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3660 EXPECT_EQ(1, app_icon_loader1->clear_count()); 3618 EXPECT_EQ(1, app_icon_loader1->clear_count());
3661 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3619 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3662 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3620 EXPECT_EQ(0, app_icon_loader2->clear_count());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3776 views::Widget* window2 = CreateArcWindow("org.chromium.arc.2"); 3734 views::Widget* window2 = CreateArcWindow("org.chromium.arc.2");
3777 ASSERT_TRUE(window2); 3735 ASSERT_TRUE(window2);
3778 3736
3779 EXPECT_FALSE(window1->IsActive()); 3737 EXPECT_FALSE(window1->IsActive());
3780 EXPECT_TRUE(window2->IsActive()); 3738 EXPECT_TRUE(window2->IsActive());
3781 3739
3782 const std::string app_id = ArcAppTest::GetAppId(appinfo); 3740 const std::string app_id = ArcAppTest::GetAppId(appinfo);
3783 3741
3784 const ash::ShelfID shelf_id = 3742 const ash::ShelfID shelf_id =
3785 launcher_controller_->GetShelfIDForAppID(app_id); 3743 launcher_controller_->GetShelfIDForAppID(app_id);
3786 LauncherItemController* item_controller = 3744 ash::ShelfItemDelegate* item_delegate =
3787 launcher_controller_->GetLauncherItemController(shelf_id); 3745 launcher_controller_->GetShelfItemDelegate(shelf_id);
3788 ASSERT_TRUE(item_controller); 3746 ASSERT_TRUE(item_delegate);
3789 3747
3790 // Selecting the item will show its application menu. It does not change the 3748 // Selecting the item will show its application menu. It does not change the
3791 // active window. 3749 // active window.
3792 SelectItem(item_controller); 3750 SelectItem(item_delegate);
3793 EXPECT_FALSE(window1->IsActive()); 3751 EXPECT_FALSE(window1->IsActive());
3794 EXPECT_TRUE(window2->IsActive()); 3752 EXPECT_TRUE(window2->IsActive());
3795 3753
3796 // Command ids are just app window indices. Note, apps are registered in 3754 // Command ids are just app window indices. Note, apps are registered in
3797 // opposite order. Last created goes in front. 3755 // opposite order. Last created goes in front.
3798 MenuItemList items = item_controller->GetAppMenuItems(0); 3756 ash::MenuItemList items = item_delegate->GetAppMenuItems(0);
3799 ASSERT_EQ(items.size(), 2U); 3757 ASSERT_EQ(items.size(), 2U);
3800 EXPECT_EQ(items[0]->command_id, 0U); 3758 EXPECT_EQ(items[0]->command_id, 0U);
3801 EXPECT_EQ(items[1]->command_id, 1U); 3759 EXPECT_EQ(items[1]->command_id, 1U);
3802 3760
3803 // Execute command to activate first window. 3761 // Execute command to activate first window.
3804 item_controller->ExecuteCommand(items[1]->command_id, 0); 3762 item_delegate->ExecuteCommand(items[1]->command_id, 0);
3805 EXPECT_TRUE(window1->IsActive()); 3763 EXPECT_TRUE(window1->IsActive());
3806 EXPECT_FALSE(window2->IsActive()); 3764 EXPECT_FALSE(window2->IsActive());
3807 3765
3808 // Selecting the item will show its application menu. It does not change the 3766 // Selecting the item will show its application menu. It does not change the
3809 // active window. 3767 // active window.
3810 SelectItem(item_controller); 3768 SelectItem(item_delegate);
3811 EXPECT_TRUE(window1->IsActive()); 3769 EXPECT_TRUE(window1->IsActive());
3812 EXPECT_FALSE(window2->IsActive()); 3770 EXPECT_FALSE(window2->IsActive());
3813 3771
3814 // Execute command to activate second window. 3772 // Execute command to activate second window.
3815 item_controller->ExecuteCommand(items[0]->command_id, 0); 3773 item_delegate->ExecuteCommand(items[0]->command_id, 0);
3816 EXPECT_FALSE(window1->IsActive()); 3774 EXPECT_FALSE(window1->IsActive());
3817 EXPECT_TRUE(window2->IsActive()); 3775 EXPECT_TRUE(window2->IsActive());
3818 } 3776 }
3819 3777
3820 namespace { 3778 namespace {
3821 3779
3822 class ChromeLauncherControllerOrientationTest 3780 class ChromeLauncherControllerOrientationTest
3823 : public ChromeLauncherControllerImplWithArcTest { 3781 : public ChromeLauncherControllerImplWithArcTest {
3824 public: 3782 public:
3825 ChromeLauncherControllerOrientationTest() {} 3783 ChromeLauncherControllerOrientationTest() {}
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
4182 4140
4183 EnablePlayStore(true); 4141 EnablePlayStore(true);
4184 4142
4185 // Pin Play Store. It should be pinned but not scheduled for deferred launch. 4143 // Pin Play Store. It should be pinned but not scheduled for deferred launch.
4186 launcher_controller_->PinAppWithID(arc::kPlayStoreAppId); 4144 launcher_controller_->PinAppWithID(arc::kPlayStoreAppId);
4187 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); 4145 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId));
4188 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp( 4146 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(
4189 arc::kPlayStoreAppId)); 4147 arc::kPlayStoreAppId));
4190 4148
4191 // Simulate click. This should schedule Play Store for deferred launch. 4149 // Simulate click. This should schedule Play Store for deferred launch.
4192 LauncherItemController* item_controller = 4150 ash::ShelfItemDelegate* item_delegate =
4193 launcher_controller_->GetLauncherItemController( 4151 launcher_controller_->GetShelfItemDelegate(
4194 launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId)); 4152 launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId));
4195 EXPECT_TRUE(item_controller); 4153 EXPECT_TRUE(item_delegate);
4196 SelectItem(item_controller); 4154 SelectItem(item_delegate);
4197 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); 4155 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId));
4198 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp( 4156 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(
4199 arc::kPlayStoreAppId)); 4157 arc::kPlayStoreAppId));
4200 } 4158 }
4201 4159
4202 // Checks the case when several app items have the same ordinal position (which 4160 // Checks the case when several app items have the same ordinal position (which
4203 // is valid case). 4161 // is valid case).
4204 TEST_F(ChromeLauncherControllerImplTest, CheckPositionConflict) { 4162 TEST_F(ChromeLauncherControllerImplTest, CheckPositionConflict) {
4205 InitLauncherController(); 4163 InitLauncherController();
4206 4164
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
4423 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4381 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4424 shelf_controller->auto_hide()); 4382 shelf_controller->auto_hide());
4425 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4383 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4426 4384
4427 PrefService* prefs = profile()->GetTestingPrefService(); 4385 PrefService* prefs = profile()->GetTestingPrefService();
4428 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4386 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4429 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4387 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4430 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4388 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4431 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4389 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4432 } 4390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698