Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 test_controller_ = new TestV2AppLauncherItemController(app_id); |
| 459 launcher_controller_.get()); | |
| 460 ash::ShelfID id = launcher_controller_->InsertAppLauncherItem( | 457 ash::ShelfID id = launcher_controller_->InsertAppLauncherItem( |
| 461 test_controller_, ash::STATUS_RUNNING, model_->item_count(), | 458 test_controller_, ash::STATUS_RUNNING, model_->item_count(), |
| 462 ash::TYPE_APP); | 459 ash::TYPE_APP); |
| 463 DCHECK(launcher_controller_->IsPlatformApp(id)); | 460 DCHECK(launcher_controller_->IsPlatformApp(id)); |
| 464 } | 461 } |
| 465 | 462 |
| 466 // Sets the stage for a multi user test. | 463 // Sets the stage for a multi user test. |
| 467 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, | 464 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, |
| 468 syncer::SyncChangeList* user_b) { | 465 syncer::SyncChangeList* user_b) { |
| 469 InitLauncherController(); | 466 InitLauncherController(); |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 970 scoped_refptr<Extension> arc_support_host_; | 967 scoped_refptr<Extension> arc_support_host_; |
| 971 | 968 |
| 972 ArcAppTest arc_test_; | 969 ArcAppTest arc_test_; |
| 973 bool auto_start_arc_test_ = false; | 970 bool auto_start_arc_test_ = false; |
| 974 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; | 971 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; |
| 975 std::unique_ptr<TestShelfModelObserver> model_observer_; | 972 std::unique_ptr<TestShelfModelObserver> model_observer_; |
| 976 ash::ShelfModel* model_ = nullptr; | 973 ash::ShelfModel* model_ = nullptr; |
| 977 std::unique_ptr<TestingProfileManager> profile_manager_; | 974 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 978 | 975 |
| 979 // |item_delegate_manager_| owns |test_controller_|. | 976 // |item_delegate_manager_| owns |test_controller_|. |
| 980 LauncherItemController* test_controller_ = nullptr; | 977 ash::ShelfItemDelegate* test_controller_ = nullptr; |
| 981 | 978 |
| 982 ExtensionService* extension_service_ = nullptr; | 979 ExtensionService* extension_service_ = nullptr; |
| 983 | 980 |
| 984 app_list::AppListSyncableService* app_service_ = nullptr; | 981 app_list::AppListSyncableService* app_service_ = nullptr; |
| 985 | 982 |
| 986 private: | 983 private: |
| 987 TestBrowserWindow* CreateTestBrowserWindowAura() { | 984 TestBrowserWindow* CreateTestBrowserWindowAura() { |
| 988 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); | 985 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); |
| 989 window->set_id(0); | 986 window->set_id(0); |
| 990 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 987 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1041 | 1038 |
| 1042 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 1039 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 1043 | 1040 |
| 1044 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); | 1041 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); |
| 1045 }; | 1042 }; |
| 1046 | 1043 |
| 1047 // A V1 windowed application. | 1044 // A V1 windowed application. |
| 1048 class V1App : public TestBrowserWindow { | 1045 class V1App : public TestBrowserWindow { |
| 1049 public: | 1046 public: |
| 1050 V1App(Profile* profile, const std::string& app_name) { | 1047 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( | 1048 Browser::CreateParams params = Browser::CreateParams::CreateForApp( |
| 1061 kCrxAppPrefix + app_name, true /* trusted_source */, gfx::Rect(), | 1049 kCrxAppPrefix + app_name, true /* trusted_source */, gfx::Rect(), |
| 1062 profile, true); | 1050 profile, true); |
| 1063 params.window = this; | 1051 params.window = this; |
| 1064 browser_.reset(new Browser(params)); | 1052 browser_.reset(new Browser(params)); |
| 1065 chrome::AddTabAt(browser_.get(), GURL(), 0, true); | 1053 chrome::AddTabAt(browser_.get(), GURL(), 0, true); |
| 1066 } | 1054 } |
| 1067 | 1055 |
| 1068 ~V1App() override { | 1056 ~V1App() override { |
| 1069 // close all tabs. Note that we do not need to destroy the browser itself. | 1057 // close all tabs. Note that we do not need to destroy the browser itself. |
| 1070 browser_->tab_strip_model()->CloseAllTabs(); | 1058 browser_->tab_strip_model()->CloseAllTabs(); |
| 1071 } | 1059 } |
| 1072 | 1060 |
| 1073 Browser* browser() { return browser_.get(); } | 1061 Browser* browser() { return browser_.get(); } |
| 1074 | 1062 |
| 1075 // TestBrowserWindow override: | |
| 1076 gfx::NativeWindow GetNativeWindow() const override { | |
| 1077 return native_window_.get(); | |
| 1078 } | |
| 1079 | |
| 1080 private: | 1063 private: |
| 1081 // The associated browser with this app. | 1064 // The associated browser with this app. |
| 1082 std::unique_ptr<Browser> browser_; | 1065 std::unique_ptr<Browser> browser_; |
| 1083 | 1066 |
| 1084 // The native window we use. | |
| 1085 std::unique_ptr<aura::Window> native_window_; | |
| 1086 | |
| 1087 DISALLOW_COPY_AND_ASSIGN(V1App); | 1067 DISALLOW_COPY_AND_ASSIGN(V1App); |
| 1088 }; | 1068 }; |
| 1089 | 1069 |
| 1090 // A V2 application window created with an |extension| and for a |profile|. | 1070 // A V2 application window created with an |extension| and for a |profile|. |
| 1091 // Upon destruction it will properly close the application; supports panels too. | 1071 // Upon destruction it will properly close the application; supports panels too. |
| 1092 class V2App { | 1072 class V2App { |
| 1093 public: | 1073 public: |
| 1094 V2App(Profile* profile, | 1074 V2App(Profile* profile, |
| 1095 const extensions::Extension* extension, | 1075 const extensions::Extension* extension, |
| 1096 extensions::AppWindow::WindowType window_type = | 1076 extensions::AppWindow::WindowType window_type = |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1234 return browser; | 1214 return browser; |
| 1235 } | 1215 } |
| 1236 | 1216 |
| 1237 // Creates a running V1 application. | 1217 // Creates a running V1 application. |
| 1238 // Note that with the use of the launcher_controller_helper as done below, | 1218 // Note that with the use of the launcher_controller_helper as done below, |
| 1239 // this is only usable with a single v1 application. | 1219 // this is only usable with a single v1 application. |
| 1240 V1App* CreateRunningV1App(Profile* profile, | 1220 V1App* CreateRunningV1App(Profile* profile, |
| 1241 const std::string& app_name, | 1221 const std::string& app_name, |
| 1242 const std::string& url) { | 1222 const std::string& url) { |
| 1243 V1App* v1_app = new V1App(profile, app_name); | 1223 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), | 1224 NavigateAndCommitActiveTabWithTitle(v1_app->browser(), GURL(url), |
| 1254 base::string16()); | 1225 base::string16()); |
| 1255 return v1_app; | 1226 return v1_app; |
| 1256 } | 1227 } |
| 1257 | 1228 |
| 1258 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; } | 1229 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; } |
| 1259 | 1230 |
| 1260 // Override BrowserWithTestWindowTest: | 1231 // Override BrowserWithTestWindowTest: |
| 1261 TestingProfile* CreateProfile() override { | 1232 TestingProfile* CreateProfile() override { |
| 1262 return CreateMultiUserProfile("user1"); | 1233 return CreateMultiUserProfile("user1"); |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1909 const ash::ShelfID shelf_id_app_2 = | 1880 const ash::ShelfID shelf_id_app_2 = |
| 1910 launcher_controller_->GetShelfIDForAppID(arc_app_id2); | 1881 launcher_controller_->GetShelfIDForAppID(arc_app_id2); |
| 1911 const ash::ShelfID shelf_id_app_3 = | 1882 const ash::ShelfID shelf_id_app_3 = |
| 1912 launcher_controller_->GetShelfIDForAppID(arc_app_id3); | 1883 launcher_controller_->GetShelfIDForAppID(arc_app_id3); |
| 1913 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); | 1884 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); |
| 1914 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); | 1885 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); |
| 1915 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); | 1886 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); |
| 1916 | 1887 |
| 1917 // We activated arc_app_id1 twice but expect one close for item controller | 1888 // We activated arc_app_id1 twice but expect one close for item controller |
| 1918 // stops launching request. | 1889 // stops launching request. |
| 1919 LauncherItemController* item_controller = | 1890 ash::ShelfItemDelegate* item_controller = |
| 1920 launcher_controller_->GetLauncherItemController(shelf_id_app_1); | 1891 launcher_controller_->GetLauncherItemController(shelf_id_app_1); |
| 1921 ASSERT_NE(nullptr, item_controller); | 1892 ASSERT_NE(nullptr, item_controller); |
| 1922 item_controller->Close(); | 1893 item_controller->Close(); |
| 1923 base::RunLoop().RunUntilIdle(); | 1894 base::RunLoop().RunUntilIdle(); |
| 1924 | 1895 |
| 1925 EXPECT_EQ(ash::kInvalidShelfID, | 1896 EXPECT_EQ(ash::kInvalidShelfID, |
| 1926 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1897 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1927 EXPECT_EQ(shelf_id_app_2, | 1898 EXPECT_EQ(shelf_id_app_2, |
| 1928 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1899 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1929 EXPECT_EQ(shelf_id_app_3, | 1900 EXPECT_EQ(shelf_id_app_3, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1970 | 1941 |
| 1971 int item_index = model_->ItemIndexByID(shelf_id); | 1942 int item_index = model_->ItemIndexByID(shelf_id); |
| 1972 ASSERT_GE(item_index, 0); | 1943 ASSERT_GE(item_index, 0); |
| 1973 | 1944 |
| 1974 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); | 1945 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); |
| 1975 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP); | 1946 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP); |
| 1976 | 1947 |
| 1977 // Play Store app is ARC app that might be represented by native Chrome | 1948 // Play Store app is ARC app that might be represented by native Chrome |
| 1978 // platform app. | 1949 // platform app. |
| 1979 AppWindowLauncherItemController* app_controller = | 1950 AppWindowLauncherItemController* app_controller = |
| 1980 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id), | 1951 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id)); |
| 1981 launcher_controller_.get()); | |
| 1982 launcher_controller_->SetItemController(shelf_id, app_controller); | 1952 launcher_controller_->SetItemController(shelf_id, app_controller); |
| 1983 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 1953 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 1984 | 1954 |
| 1985 // This launch request should be ignored in case of active app. | 1955 // This launch request should be ignored in case of active app. |
| 1986 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); | 1956 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); |
| 1987 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 1957 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 1988 | 1958 |
| 1989 // Close app but shortcut should exist. | 1959 // Close app but shortcut should exist. |
| 1990 launcher_controller_->CloseLauncherItem(shelf_id); | 1960 launcher_controller_->CloseLauncherItem(shelf_id); |
| 1991 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(app_id)); | 1961 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(app_id)); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2287 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", | 2257 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", |
| 2288 GetPinnedAppStatus()); | 2258 GetPinnedAppStatus()); |
| 2289 } | 2259 } |
| 2290 | 2260 |
| 2291 // Check that with multi profile V1 apps are properly added / removed from the | 2261 // Check that with multi profile V1 apps are properly added / removed from the |
| 2292 // shelf. | 2262 // shelf. |
| 2293 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, | 2263 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, |
| 2294 V1AppUpdateOnUserSwitch) { | 2264 V1AppUpdateOnUserSwitch) { |
| 2295 // Create a browser item in the LauncherController. | 2265 // Create a browser item in the LauncherController. |
| 2296 InitLauncherController(); | 2266 InitLauncherController(); |
| 2297 // TODO(crbug.com/654622): This test breaks with a non-null static instance. | |
|
James Cook
2017/04/04 15:34:45
Woo hoo, these are going away!
msw
2017/04/04 18:53:09
Acknowledged. (there is one left for an ARC test..
| |
| 2298 ChromeLauncherControllerImpl::set_instance_for_test(nullptr); | |
| 2299 | 2267 |
| 2300 EXPECT_EQ(2, model_->item_count()); | 2268 EXPECT_EQ(2, model_->item_count()); |
| 2301 { | 2269 { |
| 2302 // Create a "windowed gmail app". | 2270 // Create a "windowed gmail app". |
| 2303 std::unique_ptr<V1App> v1_app( | 2271 std::unique_ptr<V1App> v1_app( |
| 2304 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); | 2272 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); |
| 2305 EXPECT_EQ(3, model_->item_count()); | 2273 EXPECT_EQ(3, model_->item_count()); |
| 2306 | 2274 |
| 2307 // After switching to a second user the item should be gone. | 2275 // After switching to a second user the item should be gone. |
| 2308 std::string user2 = "user2"; | 2276 std::string user2 = "user2"; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2320 // Note we destroy now the gmail app with the closure end. | 2288 // Note we destroy now the gmail app with the closure end. |
| 2321 } | 2289 } |
| 2322 EXPECT_EQ(2, model_->item_count()); | 2290 EXPECT_EQ(2, model_->item_count()); |
| 2323 } | 2291 } |
| 2324 | 2292 |
| 2325 // Check edge cases with multi profile V1 apps in the shelf. | 2293 // Check edge cases with multi profile V1 apps in the shelf. |
| 2326 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, | 2294 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, |
| 2327 V1AppUpdateOnUserSwitchEdgecases) { | 2295 V1AppUpdateOnUserSwitchEdgecases) { |
| 2328 // Create a browser item in the LauncherController. | 2296 // Create a browser item in the LauncherController. |
| 2329 InitLauncherController(); | 2297 InitLauncherController(); |
| 2330 // TODO(crbug.com/654622): This test breaks with a non-null static instance. | |
| 2331 ChromeLauncherControllerImpl::set_instance_for_test(nullptr); | |
| 2332 | 2298 |
| 2333 // First test: Create an app when the user is not active. | 2299 // First test: Create an app when the user is not active. |
| 2334 std::string user2 = "user2"; | 2300 std::string user2 = "user2"; |
| 2335 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 2301 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 2336 const AccountId account_id2( | 2302 const AccountId account_id2( |
| 2337 multi_user_util::GetAccountIdFromProfile(profile2)); | 2303 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 2338 const AccountId account_id( | 2304 const AccountId account_id( |
| 2339 multi_user_util::GetAccountIdFromProfile(profile())); | 2305 multi_user_util::GetAccountIdFromProfile(profile())); |
| 2340 { | 2306 { |
| 2341 // Create a "windowed gmail app". | 2307 // Create a "windowed gmail app". |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 2358 EXPECT_EQ(2, model_->item_count()); | 2324 EXPECT_EQ(2, model_->item_count()); |
| 2359 SwitchActiveUser(account_id); | 2325 SwitchActiveUser(account_id); |
| 2360 EXPECT_EQ(2, model_->item_count()); | 2326 EXPECT_EQ(2, model_->item_count()); |
| 2361 } | 2327 } |
| 2362 | 2328 |
| 2363 // Check edge case where a visiting V1 app gets closed (crbug.com/321374). | 2329 // Check edge case where a visiting V1 app gets closed (crbug.com/321374). |
| 2364 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, | 2330 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, |
| 2365 V1CloseOnVisitingDesktop) { | 2331 V1CloseOnVisitingDesktop) { |
| 2366 // Create a browser item in the LauncherController. | 2332 // Create a browser item in the LauncherController. |
| 2367 InitLauncherController(); | 2333 InitLauncherController(); |
| 2368 // TODO(crbug.com/654622): This test breaks with a non-null static instance. | |
| 2369 ChromeLauncherControllerImpl::set_instance_for_test(nullptr); | |
| 2370 | 2334 |
| 2371 chrome::MultiUserWindowManager* manager = | 2335 chrome::MultiUserWindowManager* manager = |
| 2372 chrome::MultiUserWindowManager::GetInstance(); | 2336 chrome::MultiUserWindowManager::GetInstance(); |
| 2373 | 2337 |
| 2374 // First create an app when the user is active. | 2338 // First create an app when the user is active. |
| 2375 std::string user2 = "user2"; | 2339 std::string user2 = "user2"; |
| 2376 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 2340 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 2377 const AccountId account_id( | 2341 const AccountId account_id( |
| 2378 multi_user_util::GetAccountIdFromProfile(profile())); | 2342 multi_user_util::GetAccountIdFromProfile(profile())); |
| 2379 const AccountId account_id2( | 2343 const AccountId account_id2( |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2404 } | 2368 } |
| 2405 SwitchActiveUser(account_id2); | 2369 SwitchActiveUser(account_id2); |
| 2406 EXPECT_EQ(2, model_->item_count()); | 2370 EXPECT_EQ(2, model_->item_count()); |
| 2407 } | 2371 } |
| 2408 | 2372 |
| 2409 // Check edge cases with multi profile V1 apps in the shelf. | 2373 // Check edge cases with multi profile V1 apps in the shelf. |
| 2410 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, | 2374 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, |
| 2411 V1AppUpdateOnUserSwitchEdgecases2) { | 2375 V1AppUpdateOnUserSwitchEdgecases2) { |
| 2412 // Create a browser item in the LauncherController. | 2376 // Create a browser item in the LauncherController. |
| 2413 InitLauncherController(); | 2377 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 | 2378 |
| 2419 // First test: Create an app when the user is not active. | 2379 // First test: Create an app when the user is not active. |
| 2420 std::string user2 = "user2"; | 2380 std::string user2 = "user2"; |
| 2421 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 2381 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 2422 const AccountId account_id( | 2382 const AccountId account_id( |
| 2423 multi_user_util::GetAccountIdFromProfile(profile())); | 2383 multi_user_util::GetAccountIdFromProfile(profile())); |
| 2424 const AccountId account_id2( | 2384 const AccountId account_id2( |
| 2425 multi_user_util::GetAccountIdFromProfile(profile2)); | 2385 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 2426 SwitchActiveUser(account_id2); | 2386 SwitchActiveUser(account_id2); |
| 2427 { | 2387 { |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2871 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); | 2831 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); |
| 2872 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2832 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); |
| 2873 EXPECT_EQ(expected_launchers, actual_launchers); | 2833 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2874 } | 2834 } |
| 2875 | 2835 |
| 2876 // Ensure |controller| creates the expected menu items for the given shelf item. | 2836 // Ensure |controller| creates the expected menu items for the given shelf item. |
| 2877 void CheckAppMenu(ChromeLauncherControllerImpl* controller, | 2837 void CheckAppMenu(ChromeLauncherControllerImpl* controller, |
| 2878 const ash::ShelfItem& item, | 2838 const ash::ShelfItem& item, |
| 2879 size_t expected_item_count, | 2839 size_t expected_item_count, |
| 2880 base::string16 expected_item_titles[]) { | 2840 base::string16 expected_item_titles[]) { |
| 2881 MenuItemList items = controller->GetAppMenuItemsForTesting(item); | 2841 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item); |
| 2882 ASSERT_EQ(expected_item_count, items.size()); | 2842 ASSERT_EQ(expected_item_count, items.size()); |
| 2883 for (size_t i = 0; i < expected_item_count; i++) | 2843 for (size_t i = 0; i < expected_item_count; i++) |
| 2884 EXPECT_EQ(expected_item_titles[i], items[i]->label); | 2844 EXPECT_EQ(expected_item_titles[i], items[i]->label); |
| 2885 } | 2845 } |
| 2886 | 2846 |
| 2887 // Check that browsers get reflected correctly in the launcher menu. | 2847 // Check that browsers get reflected correctly in the launcher menu. |
| 2888 TEST_F(ChromeLauncherControllerImplTest, BrowserMenuGeneration) { | 2848 TEST_F(ChromeLauncherControllerImplTest, BrowserMenuGeneration) { |
| 2889 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 2849 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
| 2890 chrome::NewTab(browser()); | 2850 chrome::NewTab(browser()); |
| 2891 | 2851 |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3322 chrome::NewTab(browser()); | 3282 chrome::NewTab(browser()); |
| 3323 base::string16 title2 = ASCIIToUTF16("Test2"); | 3283 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 3324 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); | 3284 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); |
| 3325 | 3285 |
| 3326 // Check that the menu is properly set. | 3286 // Check that the menu is properly set. |
| 3327 ash::ShelfItem item_gmail; | 3287 ash::ShelfItem item_gmail; |
| 3328 item_gmail.type = ash::TYPE_PINNED_APP; | 3288 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3329 item_gmail.id = gmail_id; | 3289 item_gmail.id = gmail_id; |
| 3330 base::string16 two_menu_items[] = {title1, title2}; | 3290 base::string16 two_menu_items[] = {title1, title2}; |
| 3331 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items); | 3291 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items); |
| 3332 LauncherItemController* item_controller = | 3292 ash::ShelfItemDelegate* item_controller = |
| 3333 launcher_controller_->GetLauncherItemController(gmail_id); | 3293 launcher_controller_->GetLauncherItemController(gmail_id); |
| 3334 ASSERT_TRUE(item_controller); | 3294 ASSERT_TRUE(item_controller); |
| 3335 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 3295 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 3336 // Execute the second item in the menu, after the title and two separators, | 3296 // 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. | 3297 // this shouldn't do anything since that item is already the active tab. |
| 3338 { | 3298 { |
| 3339 ash::ShelfApplicationMenuModel menu( | 3299 ash::ShelfApplicationMenuModel menu( |
| 3340 base::string16(), | 3300 base::string16(), |
| 3341 launcher_controller_->GetAppMenuItemsForTesting(item_gmail), | 3301 launcher_controller_->GetAppMenuItemsForTesting(item_gmail), |
| 3342 item_controller); | 3302 item_controller); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 3371 base::string16 title2 = ASCIIToUTF16("Test2"); | 3331 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 3372 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); | 3332 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); |
| 3373 | 3333 |
| 3374 // Check that the menu is properly set. | 3334 // Check that the menu is properly set. |
| 3375 ash::ShelfItem item_gmail; | 3335 ash::ShelfItem item_gmail; |
| 3376 item_gmail.type = ash::TYPE_PINNED_APP; | 3336 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3377 item_gmail.id = gmail_id; | 3337 item_gmail.id = gmail_id; |
| 3378 base::string16 two_menu_items[] = {title1, title2}; | 3338 base::string16 two_menu_items[] = {title1, title2}; |
| 3379 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items); | 3339 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items); |
| 3380 | 3340 |
| 3381 LauncherItemController* item_controller = | 3341 ash::ShelfItemDelegate* item_controller = |
| 3382 launcher_controller_->GetLauncherItemController(gmail_id); | 3342 launcher_controller_->GetLauncherItemController(gmail_id); |
| 3383 ASSERT_TRUE(item_controller); | 3343 ASSERT_TRUE(item_controller); |
| 3384 int tabs = browser()->tab_strip_model()->count(); | 3344 int tabs = browser()->tab_strip_model()->count(); |
| 3385 // Activate the proper tab through the menu item. | 3345 // Activate the proper tab through the menu item. |
| 3386 { | 3346 { |
| 3387 MenuItemList items = | 3347 ash::MenuItemList items = |
| 3388 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); | 3348 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); |
| 3389 item_controller->ExecuteCommand(items[1]->command_id, ui::EF_NONE); | 3349 item_controller->ExecuteCommand(items[1]->command_id, ui::EF_NONE); |
| 3390 EXPECT_EQ(tabs, browser()->tab_strip_model()->count()); | 3350 EXPECT_EQ(tabs, browser()->tab_strip_model()->count()); |
| 3391 } | 3351 } |
| 3392 | 3352 |
| 3393 // Delete one tab through the menu item. | 3353 // Delete one tab through the menu item. |
| 3394 { | 3354 { |
| 3395 MenuItemList items = | 3355 ash::MenuItemList items = |
| 3396 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); | 3356 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); |
| 3397 item_controller->ExecuteCommand(items[1]->command_id, ui::EF_SHIFT_DOWN); | 3357 item_controller->ExecuteCommand(items[1]->command_id, ui::EF_SHIFT_DOWN); |
| 3398 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); | 3358 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); |
| 3399 } | 3359 } |
| 3400 } | 3360 } |
| 3401 | 3361 |
| 3402 // Tests that panels create launcher items correctly | 3362 // Tests that panels create launcher items correctly |
| 3403 TEST_F(ChromeLauncherControllerImplTest, AppPanels) { | 3363 TEST_F(ChromeLauncherControllerImplTest, AppPanels) { |
| 3404 InitLauncherController(); | 3364 InitLauncherController(); |
| 3405 model_observer_->clear_counts(); | 3365 model_observer_->clear_counts(); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3618 // app_icon_loader1 and app_icon_loader2 are owned by | 3578 // app_icon_loader1 and app_icon_loader2 are owned by |
| 3619 // ChromeLauncherControllerImpl. | 3579 // ChromeLauncherControllerImpl. |
| 3620 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); | 3580 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); |
| 3621 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); | 3581 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); |
| 3622 app_icon_loader1->AddSupportedApp(app_id1); | 3582 app_icon_loader1->AddSupportedApp(app_id1); |
| 3623 app_icon_loader2->AddSupportedApp(app_id2); | 3583 app_icon_loader2->AddSupportedApp(app_id2); |
| 3624 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), | 3584 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), |
| 3625 std::unique_ptr<AppIconLoader>(app_icon_loader2)); | 3585 std::unique_ptr<AppIconLoader>(app_icon_loader2)); |
| 3626 | 3586 |
| 3627 AppWindowLauncherItemController* app_controller3 = | 3587 AppWindowLauncherItemController* app_controller3 = |
| 3628 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id3), | 3588 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 app_controller3, ash::STATUS_RUNNING); |
| 3632 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3591 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
| 3633 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3592 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 3634 EXPECT_EQ(0, app_icon_loader2->fetch_count()); | 3593 EXPECT_EQ(0, app_icon_loader2->fetch_count()); |
| 3635 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3594 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3636 | 3595 |
| 3637 AppWindowLauncherItemController* app_controller2 = | 3596 AppWindowLauncherItemController* app_controller2 = |
| 3638 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id2), | 3597 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 app_controller2, ash::STATUS_RUNNING); |
| 3642 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3600 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
| 3643 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3601 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 3644 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3602 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3645 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3603 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3646 | 3604 |
| 3647 AppWindowLauncherItemController* app_controller1 = | 3605 AppWindowLauncherItemController* app_controller1 = |
| 3648 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id1), | 3606 new ExtensionAppWindowLauncherItemController(ash::AppLaunchId(app_id1)); |
| 3649 launcher_controller_.get()); | |
| 3650 | 3607 |
| 3651 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( | 3608 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( |
| 3652 app_controller1, ash::STATUS_RUNNING); | 3609 app_controller1, ash::STATUS_RUNNING); |
| 3653 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3610 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 3654 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3611 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 3655 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3612 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3656 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3613 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3657 | 3614 |
| 3658 launcher_controller_->CloseLauncherItem(shelfId1); | 3615 launcher_controller_->CloseLauncherItem(shelfId1); |
| 3659 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3616 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3776 views::Widget* window2 = CreateArcWindow("org.chromium.arc.2"); | 3733 views::Widget* window2 = CreateArcWindow("org.chromium.arc.2"); |
| 3777 ASSERT_TRUE(window2); | 3734 ASSERT_TRUE(window2); |
| 3778 | 3735 |
| 3779 EXPECT_FALSE(window1->IsActive()); | 3736 EXPECT_FALSE(window1->IsActive()); |
| 3780 EXPECT_TRUE(window2->IsActive()); | 3737 EXPECT_TRUE(window2->IsActive()); |
| 3781 | 3738 |
| 3782 const std::string app_id = ArcAppTest::GetAppId(appinfo); | 3739 const std::string app_id = ArcAppTest::GetAppId(appinfo); |
| 3783 | 3740 |
| 3784 const ash::ShelfID shelf_id = | 3741 const ash::ShelfID shelf_id = |
| 3785 launcher_controller_->GetShelfIDForAppID(app_id); | 3742 launcher_controller_->GetShelfIDForAppID(app_id); |
| 3786 LauncherItemController* item_controller = | 3743 ash::ShelfItemDelegate* item_controller = |
| 3787 launcher_controller_->GetLauncherItemController(shelf_id); | 3744 launcher_controller_->GetLauncherItemController(shelf_id); |
| 3788 ASSERT_TRUE(item_controller); | 3745 ASSERT_TRUE(item_controller); |
| 3789 | 3746 |
| 3790 // Selecting the item will show its application menu. It does not change the | 3747 // Selecting the item will show its application menu. It does not change the |
| 3791 // active window. | 3748 // active window. |
| 3792 SelectItem(item_controller); | 3749 SelectItem(item_controller); |
| 3793 EXPECT_FALSE(window1->IsActive()); | 3750 EXPECT_FALSE(window1->IsActive()); |
| 3794 EXPECT_TRUE(window2->IsActive()); | 3751 EXPECT_TRUE(window2->IsActive()); |
| 3795 | 3752 |
| 3796 // Command ids are just app window indices. Note, apps are registered in | 3753 // Command ids are just app window indices. Note, apps are registered in |
| 3797 // opposite order. Last created goes in front. | 3754 // opposite order. Last created goes in front. |
| 3798 MenuItemList items = item_controller->GetAppMenuItems(0); | 3755 ash::MenuItemList items = item_controller->GetAppMenuItems(0); |
| 3799 ASSERT_EQ(items.size(), 2U); | 3756 ASSERT_EQ(items.size(), 2U); |
| 3800 EXPECT_EQ(items[0]->command_id, 0U); | 3757 EXPECT_EQ(items[0]->command_id, 0U); |
| 3801 EXPECT_EQ(items[1]->command_id, 1U); | 3758 EXPECT_EQ(items[1]->command_id, 1U); |
| 3802 | 3759 |
| 3803 // Execute command to activate first window. | 3760 // Execute command to activate first window. |
| 3804 item_controller->ExecuteCommand(items[1]->command_id, 0); | 3761 item_controller->ExecuteCommand(items[1]->command_id, 0); |
| 3805 EXPECT_TRUE(window1->IsActive()); | 3762 EXPECT_TRUE(window1->IsActive()); |
| 3806 EXPECT_FALSE(window2->IsActive()); | 3763 EXPECT_FALSE(window2->IsActive()); |
| 3807 | 3764 |
| 3808 // Selecting the item will show its application menu. It does not change the | 3765 // Selecting the item will show its application menu. It does not change the |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4395 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 4352 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 4396 shelf_controller->auto_hide()); | 4353 shelf_controller->auto_hide()); |
| 4397 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4354 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
| 4398 | 4355 |
| 4399 PrefService* prefs = profile()->GetTestingPrefService(); | 4356 PrefService* prefs = profile()->GetTestingPrefService(); |
| 4400 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4357 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
| 4401 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4358 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
| 4402 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4359 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
| 4403 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4360 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
| 4404 } | 4361 } |
| OLD | NEW |