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.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include "apps/shell_window.h" | 7 #include "apps/shell_window.h" |
8 #include "apps/shell_window_registry.h" | 8 #include "apps/shell_window_registry.h" |
9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
11 #include "ash/display/display_controller.h" | 11 #include "ash/display/display_controller.h" |
12 #include "ash/launcher/launcher.h" | 12 #include "ash/shelf/shelf.h" |
13 #include "ash/shelf/shelf_button.h" | 13 #include "ash/shelf/shelf_button.h" |
14 #include "ash/shelf/shelf_model.h" | 14 #include "ash/shelf/shelf_model.h" |
15 #include "ash/shelf/shelf_util.h" | 15 #include "ash/shelf/shelf_util.h" |
16 #include "ash/shelf/shelf_view.h" | 16 #include "ash/shelf/shelf_view.h" |
17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
18 #include "ash/test/app_list_controller_test_api.h" | 18 #include "ash/test/app_list_controller_test_api.h" |
19 #include "ash/test/launcher_test_api.h" | 19 #include "ash/test/shelf_test_api.h" |
20 #include "ash/test/shelf_view_test_api.h" | 20 #include "ash/test/shelf_view_test_api.h" |
21 #include "ash/test/shell_test_api.h" | 21 #include "ash/test/shell_test_api.h" |
22 #include "ash/wm/window_state.h" | 22 #include "ash/wm/window_state.h" |
23 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
26 #include "chrome/browser/apps/app_browsertest_util.h" | 26 #include "chrome/browser/apps/app_browsertest_util.h" |
27 #include "chrome/browser/automation/automation_util.h" | 27 #include "chrome/browser/automation/automation_util.h" |
28 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
29 #include "chrome/browser/extensions/extension_apitest.h" | 29 #include "chrome/browser/extensions/extension_apitest.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 int icon_updates_; | 107 int icon_updates_; |
108 | 108 |
109 DISALLOW_COPY_AND_ASSIGN(TestShellWindowRegistryObserver); | 109 DISALLOW_COPY_AND_ASSIGN(TestShellWindowRegistryObserver); |
110 }; | 110 }; |
111 | 111 |
112 } // namespace | 112 } // namespace |
113 | 113 |
114 class LauncherPlatformAppBrowserTest | 114 class LauncherPlatformAppBrowserTest |
115 : public extensions::PlatformAppBrowserTest { | 115 : public extensions::PlatformAppBrowserTest { |
116 protected: | 116 protected: |
117 LauncherPlatformAppBrowserTest() : launcher_(NULL), controller_(NULL) { | 117 LauncherPlatformAppBrowserTest() : shelf_(NULL), controller_(NULL) { |
118 } | 118 } |
119 | 119 |
120 virtual ~LauncherPlatformAppBrowserTest() {} | 120 virtual ~LauncherPlatformAppBrowserTest() {} |
121 | 121 |
122 virtual void RunTestOnMainThreadLoop() OVERRIDE { | 122 virtual void RunTestOnMainThreadLoop() OVERRIDE { |
123 launcher_ = ash::Launcher::ForPrimaryDisplay(); | 123 shelf_ = ash::Shelf::ForPrimaryDisplay(); |
124 controller_ = ChromeLauncherController::instance(); | 124 controller_ = ChromeLauncherController::instance(); |
125 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); | 125 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); |
126 } | 126 } |
127 | 127 |
128 ash::ShelfModel* shelf_model() { | 128 ash::ShelfModel* shelf_model() { |
129 return ash::test::ShellTestApi(ash::Shell::GetInstance()).shelf_model(); | 129 return ash::test::ShellTestApi(ash::Shell::GetInstance()).shelf_model(); |
130 } | 130 } |
131 | 131 |
132 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& name) { | 132 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& name) { |
133 return controller_->CreateAppShortcutLauncherItem( | 133 return controller_->CreateAppShortcutLauncherItem( |
134 name, controller_->model()->item_count()); | 134 name, controller_->model()->item_count()); |
135 } | 135 } |
136 | 136 |
137 const ash::LauncherItem& GetLastLauncherItem() { | 137 const ash::LauncherItem& GetLastLauncherItem() { |
138 // Unless there are any panels, the item at index [count - 1] will be | 138 // Unless there are any panels, the item at index [count - 1] will be |
139 // the desired item. | 139 // the desired item. |
140 return shelf_model()->items()[shelf_model()->item_count() - 1]; | 140 return shelf_model()->items()[shelf_model()->item_count() - 1]; |
141 } | 141 } |
142 | 142 |
143 const ash::LauncherItem& GetLastLauncherPanelItem() { | 143 const ash::LauncherItem& GetLastLauncherPanelItem() { |
144 // Panels show up on the right side of the launcher, so the desired item | 144 // Panels show up on the right side of the shelf, so the desired item |
145 // will be the last one. | 145 // will be the last one. |
146 return shelf_model()->items()[shelf_model()->item_count() - 1]; | 146 return shelf_model()->items()[shelf_model()->item_count() - 1]; |
147 } | 147 } |
148 | 148 |
149 LauncherItemController* GetItemController(ash::LauncherID id) { | 149 LauncherItemController* GetItemController(ash::LauncherID id) { |
150 return controller_->id_to_item_controller_map_[id]; | 150 return controller_->id_to_item_controller_map_[id]; |
151 } | 151 } |
152 | 152 |
153 // Returns the number of menu items, ignoring separators. | 153 // Returns the number of menu items, ignoring separators. |
154 int GetNumApplicationMenuItems(const ash::LauncherItem& item) { | 154 int GetNumApplicationMenuItems(const ash::LauncherItem& item) { |
155 const int event_flags = 0; | 155 const int event_flags = 0; |
156 scoped_ptr<ash::ShelfMenuModel> menu(new LauncherApplicationMenuItemModel( | 156 scoped_ptr<ash::ShelfMenuModel> menu(new LauncherApplicationMenuItemModel( |
157 controller_->GetApplicationList(item, event_flags))); | 157 controller_->GetApplicationList(item, event_flags))); |
158 int num_items = 0; | 158 int num_items = 0; |
159 for (int i = 0; i < menu->GetItemCount(); ++i) { | 159 for (int i = 0; i < menu->GetItemCount(); ++i) { |
160 if (menu->GetTypeAt(i) != ui::MenuModel::TYPE_SEPARATOR) | 160 if (menu->GetTypeAt(i) != ui::MenuModel::TYPE_SEPARATOR) |
161 ++num_items; | 161 ++num_items; |
162 } | 162 } |
163 return num_items; | 163 return num_items; |
164 } | 164 } |
165 | 165 |
166 // Activate the launcher item with the given |id|. | 166 // Activate the shelf item with the given |id|. |
167 void ActivateLauncherItem(int id) { | 167 void ActivateShelfItem(int id) { |
168 launcher_->ActivateLauncherItem(id); | 168 shelf_->ActivateShelfItem(id); |
169 } | 169 } |
170 | 170 |
171 ash::Launcher* launcher_; | 171 ash::Shelf* shelf_; |
172 ChromeLauncherController* controller_; | 172 ChromeLauncherController* controller_; |
173 | 173 |
174 private: | 174 private: |
175 | 175 |
176 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest); | 176 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest); |
177 }; | 177 }; |
178 | 178 |
179 enum RipOffCommand { | 179 enum RipOffCommand { |
180 // Drag the item off the shelf and let the mouse go. | 180 // Drag the item off the shelf and let the mouse go. |
181 RIP_OFF_ITEM, | 181 RIP_OFF_ITEM, |
182 // Drag the item off the shelf, move the mouse back and then let go. | 182 // Drag the item off the shelf, move the mouse back and then let go. |
183 RIP_OFF_ITEM_AND_RETURN, | 183 RIP_OFF_ITEM_AND_RETURN, |
184 // Drag the item off the shelf and then issue a cancel command. | 184 // Drag the item off the shelf and then issue a cancel command. |
185 RIP_OFF_ITEM_AND_CANCEL, | 185 RIP_OFF_ITEM_AND_CANCEL, |
186 // Drag the item off the shelf and do not release the mouse. | 186 // Drag the item off the shelf and do not release the mouse. |
187 RIP_OFF_ITEM_AND_DONT_RELEASE_MOUSE, | 187 RIP_OFF_ITEM_AND_DONT_RELEASE_MOUSE, |
188 }; | 188 }; |
189 | 189 |
190 class LauncherAppBrowserTest : public ExtensionBrowserTest { | 190 class ShelfAppBrowserTest : public ExtensionBrowserTest { |
191 protected: | 191 protected: |
192 LauncherAppBrowserTest() : launcher_(NULL), model_(NULL), controller_(NULL) { | 192 ShelfAppBrowserTest() : shelf_(NULL), model_(NULL), controller_(NULL) { |
193 } | 193 } |
194 | 194 |
195 virtual ~LauncherAppBrowserTest() {} | 195 virtual ~ShelfAppBrowserTest() {} |
196 | 196 |
197 virtual void RunTestOnMainThreadLoop() OVERRIDE { | 197 virtual void RunTestOnMainThreadLoop() OVERRIDE { |
198 launcher_ = ash::Launcher::ForPrimaryDisplay(); | 198 shelf_ = ash::Shelf::ForPrimaryDisplay(); |
199 model_ = ash::test::ShellTestApi(ash::Shell::GetInstance()).shelf_model(); | 199 model_ = ash::test::ShellTestApi(ash::Shell::GetInstance()).shelf_model(); |
200 controller_ = ChromeLauncherController::instance(); | 200 controller_ = ChromeLauncherController::instance(); |
201 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); | 201 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); |
202 } | 202 } |
203 | 203 |
204 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { | 204 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { |
205 LauncherItemController* item_controller = | 205 LauncherItemController* item_controller = |
206 controller_->GetBrowserShortcutLauncherItemController(); | 206 controller_->GetBrowserShortcutLauncherItemController(); |
207 int items = item_controller->GetApplicationList( | 207 int items = item_controller->GetApplicationList( |
208 show_all_tabs ? ui::EF_SHIFT_DOWN : 0).size(); | 208 show_all_tabs ? ui::EF_SHIFT_DOWN : 0).size(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 EXPECT_EQ(++item_count, model_->item_count()); | 248 EXPECT_EQ(++item_count, model_->item_count()); |
249 const ash::LauncherItem& item = *model_->ItemByID(shortcut_id); | 249 const ash::LauncherItem& item = *model_->ItemByID(shortcut_id); |
250 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 250 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
251 return item.id; | 251 return item.id; |
252 } | 252 } |
253 | 253 |
254 void RemoveShortcut(ash::LauncherID id) { | 254 void RemoveShortcut(ash::LauncherID id) { |
255 controller_->Unpin(id); | 255 controller_->Unpin(id); |
256 } | 256 } |
257 | 257 |
258 // Activate the launcher item with the given |id|. | 258 // Activate the shelf item with the given |id|. |
259 void ActivateLauncherItem(int id) { | 259 void ActivateShelfItem(int id) { |
260 launcher_->ActivateLauncherItem(id); | 260 shelf_->ActivateShelfItem(id); |
261 } | 261 } |
262 | 262 |
263 ash::LauncherID PinFakeApp(const std::string& name) { | 263 ash::LauncherID PinFakeApp(const std::string& name) { |
264 return controller_->CreateAppShortcutLauncherItem( | 264 return controller_->CreateAppShortcutLauncherItem( |
265 name, model_->item_count()); | 265 name, model_->item_count()); |
266 } | 266 } |
267 | 267 |
268 // Get the index of an item which has the given type. | 268 // Get the index of an item which has the given type. |
269 int GetIndexOfShelfItemType(ash::LauncherItemType type) { | 269 int GetIndexOfShelfItemType(ash::LauncherItemType type) { |
270 return model_->GetItemIndexForType(type); | 270 return model_->GetItemIndexForType(type); |
(...skipping 22 matching lines...) Expand all Loading... |
293 // This triggers an internal cancel. Using VKEY_ESCAPE was too unreliable. | 293 // This triggers an internal cancel. Using VKEY_ESCAPE was too unreliable. |
294 button->OnMouseCaptureLost(); | 294 button->OnMouseCaptureLost(); |
295 } | 295 } |
296 if (command != RIP_OFF_ITEM_AND_DONT_RELEASE_MOUSE) { | 296 if (command != RIP_OFF_ITEM_AND_DONT_RELEASE_MOUSE) { |
297 generator->ReleaseLeftButton(); | 297 generator->ReleaseLeftButton(); |
298 base::MessageLoop::current()->RunUntilIdle(); | 298 base::MessageLoop::current()->RunUntilIdle(); |
299 test->RunMessageLoopUntilAnimationsDone(); | 299 test->RunMessageLoopUntilAnimationsDone(); |
300 } | 300 } |
301 } | 301 } |
302 | 302 |
303 ash::Launcher* launcher_; | 303 ash::Shelf* shelf_; |
304 ash::ShelfModel* model_; | 304 ash::ShelfModel* model_; |
305 ChromeLauncherController* controller_; | 305 ChromeLauncherController* controller_; |
306 | 306 |
307 private: | 307 private: |
308 | 308 |
309 DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserTest); | 309 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTest); |
310 }; | 310 }; |
311 | 311 |
312 class LauncherAppBrowserTestNoDefaultBrowser : public LauncherAppBrowserTest { | 312 class ShelfAppBrowserTestNoDefaultBrowser : public ShelfAppBrowserTest { |
313 protected: | 313 protected: |
314 LauncherAppBrowserTestNoDefaultBrowser() {} | 314 ShelfAppBrowserTestNoDefaultBrowser() {} |
315 virtual ~LauncherAppBrowserTestNoDefaultBrowser() {} | 315 virtual ~ShelfAppBrowserTestNoDefaultBrowser() {} |
316 | 316 |
317 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 317 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
318 LauncherAppBrowserTest::SetUpCommandLine(command_line); | 318 ShelfAppBrowserTest::SetUpCommandLine(command_line); |
319 command_line->AppendSwitch(switches::kNoStartupWindow); | 319 command_line->AppendSwitch(switches::kNoStartupWindow); |
320 } | 320 } |
321 | 321 |
322 private: | 322 private: |
323 | 323 |
324 DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserTestNoDefaultBrowser); | 324 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestNoDefaultBrowser); |
325 }; | 325 }; |
326 | 326 |
327 // Since the default for minimizing on click might change, I added both classes | 327 // Since the default for minimizing on click might change, I added both classes |
328 // to either get the minimize on click or not. | 328 // to either get the minimize on click or not. |
329 class LauncherAppBrowserNoMinimizeOnClick | 329 class ShelfAppBrowserNoMinimizeOnClick : public LauncherPlatformAppBrowserTest { |
330 : public LauncherPlatformAppBrowserTest { | |
331 protected: | 330 protected: |
332 LauncherAppBrowserNoMinimizeOnClick() {} | 331 ShelfAppBrowserNoMinimizeOnClick() {} |
333 virtual ~LauncherAppBrowserNoMinimizeOnClick() {} | 332 virtual ~ShelfAppBrowserNoMinimizeOnClick() {} |
334 | 333 |
335 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 334 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
336 LauncherPlatformAppBrowserTest::SetUpCommandLine(command_line); | 335 LauncherPlatformAppBrowserTest::SetUpCommandLine(command_line); |
337 command_line->AppendSwitch( | 336 command_line->AppendSwitch( |
338 switches::kDisableMinimizeOnSecondLauncherItemClick); | 337 switches::kDisableMinimizeOnSecondLauncherItemClick); |
339 } | 338 } |
340 | 339 |
341 private: | 340 private: |
342 | 341 |
343 DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserNoMinimizeOnClick); | 342 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserNoMinimizeOnClick); |
344 }; | 343 }; |
345 | 344 |
346 typedef LauncherPlatformAppBrowserTest LauncherAppBrowserMinimizeOnClick; | 345 typedef LauncherPlatformAppBrowserTest ShelfAppBrowserMinimizeOnClick; |
347 | 346 |
348 // Test that we can launch a platform app and get a running item. | 347 // Test that we can launch a platform app and get a running item. |
349 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { | 348 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { |
350 int item_count = shelf_model()->item_count(); | 349 int item_count = shelf_model()->item_count(); |
351 const Extension* extension = LoadAndLaunchPlatformApp("launch"); | 350 const Extension* extension = LoadAndLaunchPlatformApp("launch"); |
352 ShellWindow* window = CreateShellWindow(extension); | 351 ShellWindow* window = CreateShellWindow(extension); |
353 ++item_count; | 352 ++item_count; |
354 ASSERT_EQ(item_count, shelf_model()->item_count()); | 353 ASSERT_EQ(item_count, shelf_model()->item_count()); |
355 const ash::LauncherItem& item = GetLastLauncherItem(); | 354 const ash::LauncherItem& item = GetLastLauncherItem(); |
356 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 355 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 ASSERT_EQ(item_count, shelf_model()->item_count()); | 575 ASSERT_EQ(item_count, shelf_model()->item_count()); |
577 const ash::LauncherItem& item2 = GetLastLauncherItem(); | 576 const ash::LauncherItem& item2 = GetLastLauncherItem(); |
578 ash::LauncherID item_id2 = item2.id; | 577 ash::LauncherID item_id2 = item2.id; |
579 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); | 578 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); |
580 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 579 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
581 | 580 |
582 EXPECT_NE(item_id1, item_id2); | 581 EXPECT_NE(item_id1, item_id2); |
583 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); | 582 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); |
584 | 583 |
585 // Activate first one. | 584 // Activate first one. |
586 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id1)); | 585 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); |
587 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); | 586 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); |
588 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id2)->status); | 587 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id2)->status); |
589 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 588 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
590 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); | 589 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
591 | 590 |
592 // Activate second one. | 591 // Activate second one. |
593 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id2)); | 592 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id2)); |
594 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); | 593 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); |
595 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id2)->status); | 594 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id2)->status); |
596 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 595 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
597 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); | 596 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
598 | 597 |
599 // Add window for app1. This will activate it. | 598 // Add window for app1. This will activate it. |
600 ShellWindow* window1b = CreateShellWindow(extension1); | 599 ShellWindow* window1b = CreateShellWindow(extension1); |
601 ash::wm::ActivateWindow(window1b->GetNativeWindow()); | 600 ash::wm::ActivateWindow(window1b->GetNativeWindow()); |
602 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 601 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
603 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); | 602 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
604 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); | 603 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); |
605 | 604 |
606 // Activate launcher item for app1, this will activate the first app window. | 605 // Activate launcher item for app1, this will activate the first app window. |
607 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id1)); | 606 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); |
608 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 607 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
609 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); | 608 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); |
610 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id1)); | 609 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); |
611 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); | 610 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); |
612 | 611 |
613 // Activate the second app again | 612 // Activate the second app again |
614 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id2)); | 613 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id2)); |
615 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 614 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
616 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); | 615 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
617 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); | 616 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); |
618 | 617 |
619 // Activate the first app again | 618 // Activate the first app again |
620 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id1)); | 619 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); |
621 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); | 620 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); |
622 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); | 621 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
623 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 622 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
624 | 623 |
625 // Close second app. | 624 // Close second app. |
626 CloseShellWindow(window2); | 625 CloseShellWindow(window2); |
627 --item_count; | 626 --item_count; |
628 EXPECT_EQ(item_count, shelf_model()->item_count()); | 627 EXPECT_EQ(item_count, shelf_model()->item_count()); |
629 // First app should be active again. | 628 // First app should be active again. |
630 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); | 629 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); |
631 | 630 |
632 // Close first app. | 631 // Close first app. |
633 CloseShellWindow(window1b); | 632 CloseShellWindow(window1b); |
634 CloseShellWindow(window1); | 633 CloseShellWindow(window1); |
635 --item_count; | 634 --item_count; |
636 EXPECT_EQ(item_count, shelf_model()->item_count()); | 635 EXPECT_EQ(item_count, shelf_model()->item_count()); |
637 } | 636 } |
638 | 637 |
639 // Confirm that Click behavior for app windows is correnct. | 638 // Confirm that Click behavior for app windows is correnct. |
640 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserNoMinimizeOnClick, | 639 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserNoMinimizeOnClick, AppClickBehavior) { |
641 AppClickBehavior) { | |
642 // Launch a platform app and create a window for it. | 640 // Launch a platform app and create a window for it. |
643 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); | 641 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); |
644 ShellWindow* window1 = CreateShellWindow(extension1); | 642 ShellWindow* window1 = CreateShellWindow(extension1); |
645 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 643 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
646 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 644 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
647 // Confirm that a controller item was created and is the correct state. | 645 // Confirm that a controller item was created and is the correct state. |
648 const ash::LauncherItem& item1 = GetLastLauncherItem(); | 646 const ash::LauncherItem& item1 = GetLastLauncherItem(); |
649 LauncherItemController* item1_controller = GetItemController(item1.id); | 647 LauncherItemController* item1_controller = GetItemController(item1.id); |
650 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 648 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
651 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 649 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
(...skipping 16 matching lines...) Expand all Loading... |
668 // Maximizing a window should preserve state after minimize + click. | 666 // Maximizing a window should preserve state after minimize + click. |
669 window1->GetBaseWindow()->Maximize(); | 667 window1->GetBaseWindow()->Maximize(); |
670 window1->GetBaseWindow()->Minimize(); | 668 window1->GetBaseWindow()->Minimize(); |
671 item1_controller->ItemSelected(click_event); | 669 item1_controller->ItemSelected(click_event); |
672 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 670 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
673 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 671 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
674 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized()); | 672 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized()); |
675 } | 673 } |
676 | 674 |
677 // Confirm the minimizing click behavior for apps. | 675 // Confirm the minimizing click behavior for apps. |
678 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserMinimizeOnClick, | 676 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserMinimizeOnClick, |
679 PackagedAppClickBehaviorInMinimizeMode) { | 677 PackagedAppClickBehaviorInMinimizeMode) { |
680 // Launch one platform app and create a window for it. | 678 // Launch one platform app and create a window for it. |
681 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); | 679 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); |
682 ShellWindow* window1 = CreateShellWindow(extension1); | 680 ShellWindow* window1 = CreateShellWindow(extension1); |
683 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 681 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
684 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 682 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
685 | 683 |
686 // Confirm that a controller item was created and is the correct state. | 684 // Confirm that a controller item was created and is the correct state. |
687 const ash::LauncherItem& item1 = GetLastLauncherItem(); | 685 const ash::LauncherItem& item1 = GetLastLauncherItem(); |
688 LauncherItemController* item1_controller = GetItemController(item1.id); | 686 LauncherItemController* item1_controller = GetItemController(item1.id); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 } | 784 } |
787 | 785 |
788 // Test that opening an app sets the correct icon | 786 // Test that opening an app sets the correct icon |
789 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) { | 787 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) { |
790 TestShellWindowRegistryObserver test_observer(browser()->profile()); | 788 TestShellWindowRegistryObserver test_observer(browser()->profile()); |
791 | 789 |
792 // Enable experimental APIs to allow panel creation. | 790 // Enable experimental APIs to allow panel creation. |
793 CommandLine::ForCurrentProcess()->AppendSwitch( | 791 CommandLine::ForCurrentProcess()->AppendSwitch( |
794 extensions::switches::kEnableExperimentalExtensionApis); | 792 extensions::switches::kEnableExperimentalExtensionApis); |
795 | 793 |
796 int base_launcher_item_count = shelf_model()->item_count(); | 794 int base_shelf_item_count = shelf_model()->item_count(); |
797 ExtensionTestMessageListener launched_listener("Launched", false); | 795 ExtensionTestMessageListener launched_listener("Launched", false); |
798 ExtensionTestMessageListener completed_listener("Completed", false); | 796 ExtensionTestMessageListener completed_listener("Completed", false); |
799 LoadAndLaunchPlatformApp("app_icon"); | 797 LoadAndLaunchPlatformApp("app_icon"); |
800 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 798 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
801 ASSERT_TRUE(completed_listener.WaitUntilSatisfied()); | 799 ASSERT_TRUE(completed_listener.WaitUntilSatisfied()); |
802 | 800 |
803 // Now wait until the WebContent has decoded the icons and chrome has | 801 // Now wait until the WebContent has decoded the icons and chrome has |
804 // processed it. This needs to be in a loop since the renderer runs in a | 802 // processed it. This needs to be in a loop since the renderer runs in a |
805 // different process. | 803 // different process. |
806 while (test_observer.icon_updates() < 3) { | 804 while (test_observer.icon_updates() < 3) { |
807 base::RunLoop run_loop; | 805 base::RunLoop run_loop; |
808 run_loop.RunUntilIdle(); | 806 run_loop.RunUntilIdle(); |
809 } | 807 } |
810 | 808 |
811 // This test creates one shell window and one panel window. | 809 // This test creates one shell window and one panel window. |
812 int launcher_item_count = shelf_model()->item_count(); | 810 int shelf_item_count = shelf_model()->item_count(); |
813 ASSERT_EQ(base_launcher_item_count + 2, launcher_item_count); | 811 ASSERT_EQ(base_shelf_item_count + 2, shelf_item_count); |
814 // The Panel will be the last item, the app second-to-last. | 812 // The Panel will be the last item, the app second-to-last. |
815 const ash::LauncherItem& app_item = | 813 const ash::LauncherItem& app_item = |
816 shelf_model()->items()[launcher_item_count - 2]; | 814 shelf_model()->items()[shelf_item_count - 2]; |
817 const ash::LauncherItem& panel_item = | 815 const ash::LauncherItem& panel_item = |
818 shelf_model()->items()[launcher_item_count - 1]; | 816 shelf_model()->items()[shelf_item_count - 1]; |
819 const LauncherItemController* app_item_controller = | 817 const LauncherItemController* app_item_controller = |
820 GetItemController(app_item.id); | 818 GetItemController(app_item.id); |
821 const LauncherItemController* panel_item_controller = | 819 const LauncherItemController* panel_item_controller = |
822 GetItemController(panel_item.id); | 820 GetItemController(panel_item.id); |
823 // Icons for Apps are set by the ShellWindowLauncherController, so | 821 // Icons for Apps are set by the ShellWindowLauncherController, so |
824 // image_set_by_controller() should be set. | 822 // image_set_by_controller() should be set. |
825 EXPECT_TRUE(app_item_controller->image_set_by_controller()); | 823 EXPECT_TRUE(app_item_controller->image_set_by_controller()); |
826 EXPECT_TRUE(panel_item_controller->image_set_by_controller()); | 824 EXPECT_TRUE(panel_item_controller->image_set_by_controller()); |
827 // Ensure icon heights are correct (see test.js in app_icon/ test directory) | 825 // Ensure icon heights are correct (see test.js in app_icon/ test directory) |
828 EXPECT_EQ(48, app_item.image.height()); | 826 EXPECT_EQ(48, app_item.image.height()); |
829 EXPECT_EQ(64, panel_item.image.height()); | 827 EXPECT_EQ(64, panel_item.image.height()); |
830 } | 828 } |
831 | 829 |
832 // Test that we can launch an app with a shortcut. | 830 // Test that we can launch an app with a shortcut. |
833 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { | 831 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchPinned) { |
834 TabStripModel* tab_strip = browser()->tab_strip_model(); | 832 TabStripModel* tab_strip = browser()->tab_strip_model(); |
835 int tab_count = tab_strip->count(); | 833 int tab_count = tab_strip->count(); |
836 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 834 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
837 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 835 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
838 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 836 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
839 EXPECT_EQ(++tab_count, tab_strip->count()); | 837 EXPECT_EQ(++tab_count, tab_strip->count()); |
840 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 838 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
841 WebContents* tab = tab_strip->GetActiveWebContents(); | 839 WebContents* tab = tab_strip->GetActiveWebContents(); |
842 content::WebContentsDestroyedWatcher destroyed_watcher(tab); | 840 content::WebContentsDestroyedWatcher destroyed_watcher(tab); |
843 browser()->tab_strip_model()->CloseSelectedTabs(); | 841 browser()->tab_strip_model()->CloseSelectedTabs(); |
844 destroyed_watcher.Wait(); | 842 destroyed_watcher.Wait(); |
845 EXPECT_EQ(--tab_count, tab_strip->count()); | 843 EXPECT_EQ(--tab_count, tab_strip->count()); |
846 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 844 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
847 } | 845 } |
848 | 846 |
849 // Launch the app first and then create the shortcut. | 847 // Launch the app first and then create the shortcut. |
850 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchUnpinned) { | 848 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchUnpinned) { |
851 TabStripModel* tab_strip = browser()->tab_strip_model(); | 849 TabStripModel* tab_strip = browser()->tab_strip_model(); |
852 int tab_count = tab_strip->count(); | 850 int tab_count = tab_strip->count(); |
853 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, | 851 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
854 NEW_FOREGROUND_TAB); | 852 NEW_FOREGROUND_TAB); |
855 EXPECT_EQ(++tab_count, tab_strip->count()); | 853 EXPECT_EQ(++tab_count, tab_strip->count()); |
856 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 854 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
857 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 855 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
858 WebContents* tab = tab_strip->GetActiveWebContents(); | 856 WebContents* tab = tab_strip->GetActiveWebContents(); |
859 content::WebContentsDestroyedWatcher destroyed_watcher(tab); | 857 content::WebContentsDestroyedWatcher destroyed_watcher(tab); |
860 browser()->tab_strip_model()->CloseSelectedTabs(); | 858 browser()->tab_strip_model()->CloseSelectedTabs(); |
861 destroyed_watcher.Wait(); | 859 destroyed_watcher.Wait(); |
862 EXPECT_EQ(--tab_count, tab_strip->count()); | 860 EXPECT_EQ(--tab_count, tab_strip->count()); |
863 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 861 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
864 } | 862 } |
865 | 863 |
866 // Launches an app in the background and then tries to open it. This is test for | 864 // Launches an app in the background and then tries to open it. This is test for |
867 // a crash we had. | 865 // a crash we had. |
868 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchInBackground) { | 866 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchInBackground) { |
869 TabStripModel* tab_strip = browser()->tab_strip_model(); | 867 TabStripModel* tab_strip = browser()->tab_strip_model(); |
870 int tab_count = tab_strip->count(); | 868 int tab_count = tab_strip->count(); |
871 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, | 869 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
872 NEW_BACKGROUND_TAB); | 870 NEW_BACKGROUND_TAB); |
873 EXPECT_EQ(++tab_count, tab_strip->count()); | 871 EXPECT_EQ(++tab_count, tab_strip->count()); |
874 ChromeLauncherController::instance()->LaunchApp(last_loaded_extension_id(), | 872 ChromeLauncherController::instance()->LaunchApp(last_loaded_extension_id(), |
875 ash::LAUNCH_FROM_UNKNOWN, | 873 ash::LAUNCH_FROM_UNKNOWN, |
876 0); | 874 0); |
877 } | 875 } |
878 | 876 |
879 // Confirm that clicking a icon for an app running in one of 2 maxmized windows | 877 // Confirm that clicking a icon for an app running in one of 2 maxmized windows |
880 // activates the right window. | 878 // activates the right window. |
881 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchMaximized) { | 879 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchMaximized) { |
882 aura::Window* window1 = browser()->window()->GetNativeWindow(); | 880 aura::Window* window1 = browser()->window()->GetNativeWindow(); |
883 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1); | 881 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1); |
884 window1_state->Maximize(); | 882 window1_state->Maximize(); |
885 content::WindowedNotificationObserver open_observer( | 883 content::WindowedNotificationObserver open_observer( |
886 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 884 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
887 content::NotificationService::AllSources()); | 885 content::NotificationService::AllSources()); |
888 chrome::NewEmptyWindow(browser()->profile(), chrome::HOST_DESKTOP_TYPE_ASH); | 886 chrome::NewEmptyWindow(browser()->profile(), chrome::HOST_DESKTOP_TYPE_ASH); |
889 open_observer.Wait(); | 887 open_observer.Wait(); |
890 Browser* browser2 = content::Source<Browser>(open_observer.source()).ptr(); | 888 Browser* browser2 = content::Source<Browser>(open_observer.source()).ptr(); |
891 aura::Window* window2 = browser2->window()->GetNativeWindow(); | 889 aura::Window* window2 = browser2->window()->GetNativeWindow(); |
892 TabStripModel* tab_strip = browser2->tab_strip_model(); | 890 TabStripModel* tab_strip = browser2->tab_strip_model(); |
893 int tab_count = tab_strip->count(); | 891 int tab_count = tab_strip->count(); |
894 ash::wm::GetWindowState(window2)->Maximize(); | 892 ash::wm::GetWindowState(window2)->Maximize(); |
895 | 893 |
896 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 894 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
897 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 895 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
898 EXPECT_EQ(++tab_count, tab_strip->count()); | 896 EXPECT_EQ(++tab_count, tab_strip->count()); |
899 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 897 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
900 | 898 |
901 window1->Show(); | 899 window1->Show(); |
902 window1_state->Activate(); | 900 window1_state->Activate(); |
903 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut_id)).status); | 901 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut_id)).status); |
904 | 902 |
905 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 903 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
906 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 904 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
907 } | 905 } |
908 | 906 |
909 // Activating the same app multiple times should launch only a single copy. | 907 // Activating the same app multiple times should launch only a single copy. |
910 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ActivateApp) { | 908 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ActivateApp) { |
911 TabStripModel* tab_strip = browser()->tab_strip_model(); | 909 TabStripModel* tab_strip = browser()->tab_strip_model(); |
912 int tab_count = tab_strip->count(); | 910 int tab_count = tab_strip->count(); |
913 const Extension* extension = | 911 const Extension* extension = |
914 LoadExtension(test_data_dir_.AppendASCII("app1")); | 912 LoadExtension(test_data_dir_.AppendASCII("app1")); |
915 | 913 |
916 ChromeLauncherController::instance()->ActivateApp(extension->id(), | 914 ChromeLauncherController::instance()->ActivateApp(extension->id(), |
917 ash::LAUNCH_FROM_UNKNOWN, | 915 ash::LAUNCH_FROM_UNKNOWN, |
918 0); | 916 0); |
919 EXPECT_EQ(++tab_count, tab_strip->count()); | 917 EXPECT_EQ(++tab_count, tab_strip->count()); |
920 ChromeLauncherController::instance()->ActivateApp(extension->id(), | 918 ChromeLauncherController::instance()->ActivateApp(extension->id(), |
921 ash::LAUNCH_FROM_UNKNOWN, | 919 ash::LAUNCH_FROM_UNKNOWN, |
922 0); | 920 0); |
923 EXPECT_EQ(tab_count, tab_strip->count()); | 921 EXPECT_EQ(tab_count, tab_strip->count()); |
924 } | 922 } |
925 | 923 |
926 // Launching the same app multiple times should launch a copy for each call. | 924 // Launching the same app multiple times should launch a copy for each call. |
927 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchApp) { | 925 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchApp) { |
928 TabStripModel* tab_strip = browser()->tab_strip_model(); | 926 TabStripModel* tab_strip = browser()->tab_strip_model(); |
929 int tab_count = tab_strip->count(); | 927 int tab_count = tab_strip->count(); |
930 const Extension* extension = | 928 const Extension* extension = |
931 LoadExtension(test_data_dir_.AppendASCII("app1")); | 929 LoadExtension(test_data_dir_.AppendASCII("app1")); |
932 | 930 |
933 ChromeLauncherController::instance()->LaunchApp(extension->id(), | 931 ChromeLauncherController::instance()->LaunchApp(extension->id(), |
934 ash::LAUNCH_FROM_UNKNOWN, | 932 ash::LAUNCH_FROM_UNKNOWN, |
935 0); | 933 0); |
936 EXPECT_EQ(++tab_count, tab_strip->count()); | 934 EXPECT_EQ(++tab_count, tab_strip->count()); |
937 ChromeLauncherController::instance()->LaunchApp(extension->id(), | 935 ChromeLauncherController::instance()->LaunchApp(extension->id(), |
938 ash::LAUNCH_FROM_UNKNOWN, | 936 ash::LAUNCH_FROM_UNKNOWN, |
939 0); | 937 0); |
940 EXPECT_EQ(++tab_count, tab_strip->count()); | 938 EXPECT_EQ(++tab_count, tab_strip->count()); |
941 } | 939 } |
942 | 940 |
943 // Launch 2 apps and toggle which is active. | 941 // Launch 2 apps and toggle which is active. |
944 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleApps) { | 942 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultipleApps) { |
945 int item_count = model_->item_count(); | 943 int item_count = model_->item_count(); |
946 TabStripModel* tab_strip = browser()->tab_strip_model(); | 944 TabStripModel* tab_strip = browser()->tab_strip_model(); |
947 int tab_count = tab_strip->count(); | 945 int tab_count = tab_strip->count(); |
948 ash::LauncherID shortcut1 = CreateShortcut("app1"); | 946 ash::LauncherID shortcut1 = CreateShortcut("app1"); |
949 EXPECT_EQ(++item_count, model_->item_count()); | 947 EXPECT_EQ(++item_count, model_->item_count()); |
950 ash::LauncherID shortcut2 = CreateShortcut("app2"); | 948 ash::LauncherID shortcut2 = CreateShortcut("app2"); |
951 EXPECT_EQ(++item_count, model_->item_count()); | 949 EXPECT_EQ(++item_count, model_->item_count()); |
952 | 950 |
953 // Launch first app. | 951 // Launch first app. |
954 ActivateLauncherItem(model_->ItemIndexByID(shortcut1)); | 952 ActivateShelfItem(model_->ItemIndexByID(shortcut1)); |
955 EXPECT_EQ(++tab_count, tab_strip->count()); | 953 EXPECT_EQ(++tab_count, tab_strip->count()); |
956 WebContents* tab1 = tab_strip->GetActiveWebContents(); | 954 WebContents* tab1 = tab_strip->GetActiveWebContents(); |
957 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); | 955 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); |
958 | 956 |
959 // Launch second app. | 957 // Launch second app. |
960 ActivateLauncherItem(model_->ItemIndexByID(shortcut2)); | 958 ActivateShelfItem(model_->ItemIndexByID(shortcut2)); |
961 EXPECT_EQ(++tab_count, tab_strip->count()); | 959 EXPECT_EQ(++tab_count, tab_strip->count()); |
962 WebContents* tab2 = tab_strip->GetActiveWebContents(); | 960 WebContents* tab2 = tab_strip->GetActiveWebContents(); |
963 ASSERT_NE(tab1, tab2); | 961 ASSERT_NE(tab1, tab2); |
964 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); | 962 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); |
965 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); | 963 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); |
966 | 964 |
967 // Reactivate first app. | 965 // Reactivate first app. |
968 ActivateLauncherItem(model_->ItemIndexByID(shortcut1)); | 966 ActivateShelfItem(model_->ItemIndexByID(shortcut1)); |
969 EXPECT_EQ(tab_count, tab_strip->count()); | 967 EXPECT_EQ(tab_count, tab_strip->count()); |
970 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1); | 968 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1); |
971 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); | 969 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); |
972 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); | 970 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); |
973 | 971 |
974 // Open second tab for second app. This should activate it. | 972 // Open second tab for second app. This should activate it. |
975 ui_test_utils::NavigateToURLWithDisposition( | 973 ui_test_utils::NavigateToURLWithDisposition( |
976 browser(), | 974 browser(), |
977 GURL("http://www.example.com/path3/foo.html"), | 975 GURL("http://www.example.com/path3/foo.html"), |
978 NEW_FOREGROUND_TAB, | 976 NEW_FOREGROUND_TAB, |
979 0); | 977 0); |
980 EXPECT_EQ(++tab_count, tab_strip->count()); | 978 EXPECT_EQ(++tab_count, tab_strip->count()); |
981 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); | 979 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); |
982 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); | 980 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); |
983 | 981 |
984 // Reactivate first app. | 982 // Reactivate first app. |
985 ActivateLauncherItem(model_->ItemIndexByID(shortcut1)); | 983 ActivateShelfItem(model_->ItemIndexByID(shortcut1)); |
986 EXPECT_EQ(tab_count, tab_strip->count()); | 984 EXPECT_EQ(tab_count, tab_strip->count()); |
987 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1); | 985 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1); |
988 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); | 986 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); |
989 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); | 987 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); |
990 | 988 |
991 // And second again. This time the second tab should become active. | 989 // And second again. This time the second tab should become active. |
992 ActivateLauncherItem(model_->ItemIndexByID(shortcut2)); | 990 ActivateShelfItem(model_->ItemIndexByID(shortcut2)); |
993 EXPECT_EQ(tab_count, tab_strip->count()); | 991 EXPECT_EQ(tab_count, tab_strip->count()); |
994 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab2); | 992 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab2); |
995 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); | 993 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); |
996 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); | 994 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); |
997 } | 995 } |
998 | 996 |
999 // Confirm that a page can be navigated from and to while maintaining the | 997 // Confirm that a page can be navigated from and to while maintaining the |
1000 // correct running state. | 998 // correct running state. |
1001 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, Navigation) { | 999 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, Navigation) { |
1002 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1000 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
1003 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 1001 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
1004 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 1002 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
1005 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 1003 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
1006 | 1004 |
1007 // Navigate away. | 1005 // Navigate away. |
1008 ui_test_utils::NavigateToURL( | 1006 ui_test_utils::NavigateToURL( |
1009 browser(), GURL("http://www.example.com/path0/bar.html")); | 1007 browser(), GURL("http://www.example.com/path0/bar.html")); |
1010 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 1008 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
1011 | 1009 |
1012 // Navigate back. | 1010 // Navigate back. |
1013 ui_test_utils::NavigateToURL( | 1011 ui_test_utils::NavigateToURL( |
1014 browser(), GURL("http://www.example.com/path1/foo.html")); | 1012 browser(), GURL("http://www.example.com/path1/foo.html")); |
1015 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 1013 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
1016 } | 1014 } |
1017 | 1015 |
1018 // Confirm that a tab can be moved between browsers while maintaining the | 1016 // Confirm that a tab can be moved between browsers while maintaining the |
1019 // correct running state. | 1017 // correct running state. |
1020 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, TabDragAndDrop) { | 1018 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, TabDragAndDrop) { |
1021 TabStripModel* tab_strip_model1 = browser()->tab_strip_model(); | 1019 TabStripModel* tab_strip_model1 = browser()->tab_strip_model(); |
1022 EXPECT_EQ(1, tab_strip_model1->count()); | 1020 EXPECT_EQ(1, tab_strip_model1->count()); |
1023 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); | 1021 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); |
1024 EXPECT_TRUE(browser_index >= 0); | 1022 EXPECT_TRUE(browser_index >= 0); |
1025 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1023 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
1026 | 1024 |
1027 // Create a shortcut for app1. | 1025 // Create a shortcut for app1. |
1028 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1026 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
1029 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); | 1027 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); |
1030 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 1028 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
1031 | 1029 |
1032 // Activate app1 and check its item status. | 1030 // Activate app1 and check its item status. |
1033 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 1031 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
1034 EXPECT_EQ(2, tab_strip_model1->count()); | 1032 EXPECT_EQ(2, tab_strip_model1->count()); |
1035 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status); | 1033 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status); |
1036 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 1034 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
1037 | 1035 |
1038 // Create a new browser with blank tab. | 1036 // Create a new browser with blank tab. |
1039 Browser* browser2 = CreateBrowser(profile()); | 1037 Browser* browser2 = CreateBrowser(profile()); |
1040 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 1038 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
1041 TabStripModel* tab_strip_model2 = browser2->tab_strip_model(); | 1039 TabStripModel* tab_strip_model2 = browser2->tab_strip_model(); |
1042 EXPECT_EQ(1, tab_strip_model2->count()); | 1040 EXPECT_EQ(1, tab_strip_model2->count()); |
1043 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); | 1041 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); |
1044 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut_id)).status); | 1042 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut_id)).status); |
1045 | 1043 |
1046 // Detach a tab at index 1 (app1) from |tab_strip_model1| and insert it as an | 1044 // Detach a tab at index 1 (app1) from |tab_strip_model1| and insert it as an |
1047 // active tab at index 1 to |tab_strip_model2|. | 1045 // active tab at index 1 to |tab_strip_model2|. |
1048 content::WebContents* detached_tab = tab_strip_model1->DetachWebContentsAt(1); | 1046 content::WebContents* detached_tab = tab_strip_model1->DetachWebContentsAt(1); |
1049 tab_strip_model2->InsertWebContentsAt(1, | 1047 tab_strip_model2->InsertWebContentsAt(1, |
1050 detached_tab, | 1048 detached_tab, |
1051 TabStripModel::ADD_ACTIVE); | 1049 TabStripModel::ADD_ACTIVE); |
1052 EXPECT_EQ(1, tab_strip_model1->count()); | 1050 EXPECT_EQ(1, tab_strip_model1->count()); |
1053 EXPECT_EQ(2, tab_strip_model2->count()); | 1051 EXPECT_EQ(2, tab_strip_model2->count()); |
1054 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status); | 1052 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status); |
1055 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 1053 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
1056 | 1054 |
1057 tab_strip_model1->CloseAllTabs(); | 1055 tab_strip_model1->CloseAllTabs(); |
1058 tab_strip_model2->CloseAllTabs(); | 1056 tab_strip_model2->CloseAllTabs(); |
1059 } | 1057 } |
1060 | 1058 |
1061 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleOwnedTabs) { | 1059 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultipleOwnedTabs) { |
1062 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1060 TabStripModel* tab_strip = browser()->tab_strip_model(); |
1063 int tab_count = tab_strip->count(); | 1061 int tab_count = tab_strip->count(); |
1064 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1062 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
1065 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 1063 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
1066 EXPECT_EQ(++tab_count, tab_strip->count()); | 1064 EXPECT_EQ(++tab_count, tab_strip->count()); |
1067 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1065 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
1068 WebContents* first_tab = tab_strip->GetActiveWebContents(); | 1066 WebContents* first_tab = tab_strip->GetActiveWebContents(); |
1069 | 1067 |
1070 // Create new tab owned by app. | 1068 // Create new tab owned by app. |
1071 ui_test_utils::NavigateToURLWithDisposition( | 1069 ui_test_utils::NavigateToURLWithDisposition( |
1072 browser(), | 1070 browser(), |
1073 GURL("http://www.example.com/path2/bar.html"), | 1071 GURL("http://www.example.com/path2/bar.html"), |
1074 NEW_FOREGROUND_TAB, | 1072 NEW_FOREGROUND_TAB, |
1075 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1073 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1076 EXPECT_EQ(++tab_count, tab_strip->count()); | 1074 EXPECT_EQ(++tab_count, tab_strip->count()); |
1077 // Confirm app is still active. | 1075 // Confirm app is still active. |
1078 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1076 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
1079 | 1077 |
1080 // Create new tab not owned by app. | 1078 // Create new tab not owned by app. |
1081 ui_test_utils::NavigateToURLWithDisposition( | 1079 ui_test_utils::NavigateToURLWithDisposition( |
1082 browser(), | 1080 browser(), |
1083 GURL("http://www.example.com/path3/foo.html"), | 1081 GURL("http://www.example.com/path3/foo.html"), |
1084 NEW_FOREGROUND_TAB, | 1082 NEW_FOREGROUND_TAB, |
1085 0); | 1083 0); |
1086 EXPECT_EQ(++tab_count, tab_strip->count()); | 1084 EXPECT_EQ(++tab_count, tab_strip->count()); |
1087 // No longer active. | 1085 // No longer active. |
1088 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); | 1086 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); |
1089 | 1087 |
1090 // Activating app makes first tab active again. | 1088 // Activating app makes first tab active again. |
1091 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 1089 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
1092 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1090 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
1093 EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab); | 1091 EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab); |
1094 } | 1092 } |
1095 | 1093 |
1096 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilter) { | 1094 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, RefocusFilter) { |
1097 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1095 TabStripModel* tab_strip = browser()->tab_strip_model(); |
1098 int tab_count = tab_strip->count(); | 1096 int tab_count = tab_strip->count(); |
1099 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1097 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
1100 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 1098 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
1101 EXPECT_EQ(++tab_count, tab_strip->count()); | 1099 EXPECT_EQ(++tab_count, tab_strip->count()); |
1102 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1100 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
1103 WebContents* first_tab = tab_strip->GetActiveWebContents(); | 1101 WebContents* first_tab = tab_strip->GetActiveWebContents(); |
1104 | 1102 |
1105 controller_->SetRefocusURLPatternForTest( | 1103 controller_->SetRefocusURLPatternForTest( |
1106 shortcut_id, GURL("http://www.example.com/path1/*")); | 1104 shortcut_id, GURL("http://www.example.com/path1/*")); |
1107 // Create new tab owned by app. | 1105 // Create new tab owned by app. |
1108 ui_test_utils::NavigateToURLWithDisposition( | 1106 ui_test_utils::NavigateToURLWithDisposition( |
1109 browser(), | 1107 browser(), |
1110 GURL("http://www.example.com/path2/bar.html"), | 1108 GURL("http://www.example.com/path2/bar.html"), |
1111 NEW_FOREGROUND_TAB, | 1109 NEW_FOREGROUND_TAB, |
1112 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1110 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1113 EXPECT_EQ(++tab_count, tab_strip->count()); | 1111 EXPECT_EQ(++tab_count, tab_strip->count()); |
1114 // Confirm app is still active. | 1112 // Confirm app is still active. |
1115 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1113 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
1116 | 1114 |
1117 // Create new tab not owned by app. | 1115 // Create new tab not owned by app. |
1118 ui_test_utils::NavigateToURLWithDisposition( | 1116 ui_test_utils::NavigateToURLWithDisposition( |
1119 browser(), | 1117 browser(), |
1120 GURL("http://www.example.com/path3/foo.html"), | 1118 GURL("http://www.example.com/path3/foo.html"), |
1121 NEW_FOREGROUND_TAB, | 1119 NEW_FOREGROUND_TAB, |
1122 0); | 1120 0); |
1123 EXPECT_EQ(++tab_count, tab_strip->count()); | 1121 EXPECT_EQ(++tab_count, tab_strip->count()); |
1124 // No longer active. | 1122 // No longer active. |
1125 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); | 1123 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); |
1126 | 1124 |
1127 // Activating app makes first tab active again, because second tab isn't | 1125 // Activating app makes first tab active again, because second tab isn't |
1128 // in its refocus url path. | 1126 // in its refocus url path. |
1129 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 1127 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
1130 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1128 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
1131 EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab); | 1129 EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab); |
1132 } | 1130 } |
1133 | 1131 |
1134 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilterLaunch) { | 1132 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, RefocusFilterLaunch) { |
1135 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1133 TabStripModel* tab_strip = browser()->tab_strip_model(); |
1136 int tab_count = tab_strip->count(); | 1134 int tab_count = tab_strip->count(); |
1137 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1135 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
1138 controller_->SetRefocusURLPatternForTest( | 1136 controller_->SetRefocusURLPatternForTest( |
1139 shortcut_id, GURL("http://www.example.com/path1/*")); | 1137 shortcut_id, GURL("http://www.example.com/path1/*")); |
1140 | 1138 |
1141 // Create new tab. | 1139 // Create new tab. |
1142 ui_test_utils::NavigateToURLWithDisposition( | 1140 ui_test_utils::NavigateToURLWithDisposition( |
1143 browser(), | 1141 browser(), |
1144 GURL("http://www.example2.com/path2/bar.html"), | 1142 GURL("http://www.example2.com/path2/bar.html"), |
1145 NEW_FOREGROUND_TAB, | 1143 NEW_FOREGROUND_TAB, |
1146 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1144 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1147 EXPECT_EQ(++tab_count, tab_strip->count()); | 1145 EXPECT_EQ(++tab_count, tab_strip->count()); |
1148 WebContents* first_tab = tab_strip->GetActiveWebContents(); | 1146 WebContents* first_tab = tab_strip->GetActiveWebContents(); |
1149 // Confirm app is not active. | 1147 // Confirm app is not active. |
1150 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1148 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
1151 | 1149 |
1152 // Activating app should launch new tab, because second tab isn't | 1150 // Activating app should launch new tab, because second tab isn't |
1153 // in its refocus url path. | 1151 // in its refocus url path. |
1154 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 1152 ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
1155 EXPECT_EQ(++tab_count, tab_strip->count()); | 1153 EXPECT_EQ(++tab_count, tab_strip->count()); |
1156 WebContents* second_tab = tab_strip->GetActiveWebContents(); | 1154 WebContents* second_tab = tab_strip->GetActiveWebContents(); |
1157 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1155 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
1158 EXPECT_NE(first_tab, second_tab); | 1156 EXPECT_NE(first_tab, second_tab); |
1159 EXPECT_EQ(tab_strip->GetActiveWebContents(), second_tab); | 1157 EXPECT_EQ(tab_strip->GetActiveWebContents(), second_tab); |
1160 } | 1158 } |
1161 | 1159 |
1162 // Check the launcher activation state for applications and browser. | 1160 // Check the launcher activation state for applications and browser. |
1163 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ActivationStateCheck) { | 1161 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ActivationStateCheck) { |
1164 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1162 TabStripModel* tab_strip = browser()->tab_strip_model(); |
1165 // Get the browser item index | 1163 // Get the browser item index |
1166 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); | 1164 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); |
1167 EXPECT_TRUE(browser_index >= 0); | 1165 EXPECT_TRUE(browser_index >= 0); |
1168 | 1166 |
1169 // Even though we are just comming up, the browser should be active. | 1167 // Even though we are just comming up, the browser should be active. |
1170 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); | 1168 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); |
1171 | 1169 |
1172 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1170 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
1173 controller_->SetRefocusURLPatternForTest( | 1171 controller_->SetRefocusURLPatternForTest( |
(...skipping 22 matching lines...) Expand all Loading... |
1196 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); | 1194 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); |
1197 | 1195 |
1198 ash::wm::DeactivateWindow(browser()->window()->GetNativeWindow()); | 1196 ash::wm::DeactivateWindow(browser()->window()->GetNativeWindow()); |
1199 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1197 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
1200 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status); | 1198 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status); |
1201 } | 1199 } |
1202 | 1200 |
1203 // Check that the launcher activation state for a V1 application stays closed | 1201 // Check that the launcher activation state for a V1 application stays closed |
1204 // even after an asynchronous browser event comes in after the tab got | 1202 // even after an asynchronous browser event comes in after the tab got |
1205 // destroyed. | 1203 // destroyed. |
1206 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, AsyncActivationStateCheck) { | 1204 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, AsyncActivationStateCheck) { |
1207 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1205 TabStripModel* tab_strip = browser()->tab_strip_model(); |
1208 | 1206 |
1209 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1207 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
1210 controller_->SetRefocusURLPatternForTest( | 1208 controller_->SetRefocusURLPatternForTest( |
1211 shortcut_id, GURL("http://www.example.com/path1/*")); | 1209 shortcut_id, GURL("http://www.example.com/path1/*")); |
1212 | 1210 |
1213 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1211 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
1214 | 1212 |
1215 // Create new tab which would be the running app. | 1213 // Create new tab which would be the running app. |
1216 ui_test_utils::NavigateToURLWithDisposition( | 1214 ui_test_utils::NavigateToURLWithDisposition( |
1217 browser(), | 1215 browser(), |
1218 GURL("http://www.example.com/path1/bar.html"), | 1216 GURL("http://www.example.com/path1/bar.html"), |
1219 NEW_FOREGROUND_TAB, | 1217 NEW_FOREGROUND_TAB, |
1220 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1218 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1221 | 1219 |
1222 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1220 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
1223 // To address the issue of crbug.com/174050, the tab we are about to close | 1221 // To address the issue of crbug.com/174050, the tab we are about to close |
1224 // has to be active. | 1222 // has to be active. |
1225 tab_strip->ActivateTabAt(1, false); | 1223 tab_strip->ActivateTabAt(1, false); |
1226 EXPECT_EQ(1, tab_strip->active_index()); | 1224 EXPECT_EQ(1, tab_strip->active_index()); |
1227 | 1225 |
1228 // Close the web contents. | 1226 // Close the web contents. |
1229 tab_strip->CloseWebContentsAt(1, TabStripModel::CLOSE_NONE); | 1227 tab_strip->CloseWebContentsAt(1, TabStripModel::CLOSE_NONE); |
1230 // The status should now be set to closed. | 1228 // The status should now be set to closed. |
1231 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1229 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
1232 } | 1230 } |
1233 | 1231 |
1234 // Checks that a windowed application does not add an item to the browser list. | 1232 // Checks that a windowed application does not add an item to the browser list. |
1235 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestNoDefaultBrowser, | 1233 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
1236 WindowedAppDoesNotAddToBrowser) { | 1234 WindowedAppDoesNotAddToBrowser) { |
1237 // Get the number of items in the browser menu. | 1235 // Get the number of items in the browser menu. |
1238 size_t items = NumberOfDetectedLauncherBrowsers(false); | 1236 size_t items = NumberOfDetectedLauncherBrowsers(false); |
1239 size_t running_browser = chrome::GetTotalBrowserCount(); | 1237 size_t running_browser = chrome::GetTotalBrowserCount(); |
1240 EXPECT_EQ(0u, items); | 1238 EXPECT_EQ(0u, items); |
1241 EXPECT_EQ(0u, running_browser); | 1239 EXPECT_EQ(0u, running_browser); |
1242 | 1240 |
1243 LoadAndLaunchExtension( | 1241 LoadAndLaunchExtension( |
1244 "app1", extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW); | 1242 "app1", extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW); |
1245 | 1243 |
1246 // No new browser should get detected, even though one more is running. | 1244 // No new browser should get detected, even though one more is running. |
1247 EXPECT_EQ(0u, NumberOfDetectedLauncherBrowsers(false)); | 1245 EXPECT_EQ(0u, NumberOfDetectedLauncherBrowsers(false)); |
1248 EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount()); | 1246 EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount()); |
1249 | 1247 |
1250 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); | 1248 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); |
1251 | 1249 |
1252 // A new browser should get detected and one more should be running. | 1250 // A new browser should get detected and one more should be running. |
1253 EXPECT_EQ(NumberOfDetectedLauncherBrowsers(false), 1u); | 1251 EXPECT_EQ(NumberOfDetectedLauncherBrowsers(false), 1u); |
1254 EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount()); | 1252 EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount()); |
1255 } | 1253 } |
1256 | 1254 |
1257 // Checks the functionality to enumerate all browsers vs. all tabs. | 1255 // Checks the functionality to enumerate all browsers vs. all tabs. |
1258 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestNoDefaultBrowser, | 1256 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
1259 EnumerateALlBrowsersAndTabs) { | 1257 EnumerateALlBrowsersAndTabs) { |
1260 // Create at least one browser. | 1258 // Create at least one browser. |
1261 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); | 1259 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); |
1262 size_t browsers = NumberOfDetectedLauncherBrowsers(false); | 1260 size_t browsers = NumberOfDetectedLauncherBrowsers(false); |
1263 size_t tabs = NumberOfDetectedLauncherBrowsers(true); | 1261 size_t tabs = NumberOfDetectedLauncherBrowsers(true); |
1264 | 1262 |
1265 // Create a second browser. | 1263 // Create a second browser. |
1266 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); | 1264 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); |
1267 | 1265 |
1268 EXPECT_EQ(++browsers, NumberOfDetectedLauncherBrowsers(false)); | 1266 EXPECT_EQ(++browsers, NumberOfDetectedLauncherBrowsers(false)); |
1269 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); | 1267 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); |
1270 | 1268 |
1271 // Create only a tab. | 1269 // Create only a tab. |
1272 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, | 1270 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
1273 NEW_FOREGROUND_TAB); | 1271 NEW_FOREGROUND_TAB); |
1274 | 1272 |
1275 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false)); | 1273 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false)); |
1276 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); | 1274 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); |
1277 } | 1275 } |
1278 | 1276 |
1279 // Check that the keyboard activation of a launcher item tabs properly through | 1277 // Check that the keyboard activation of a launcher item tabs properly through |
1280 // the items at hand. | 1278 // the items at hand. |
1281 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, AltNumberTabsTabbing) { | 1279 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, AltNumberTabsTabbing) { |
1282 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1280 TabStripModel* tab_strip = browser()->tab_strip_model(); |
1283 | 1281 |
1284 ash::LauncherID shortcut_id = CreateShortcut("app"); | 1282 ash::LauncherID shortcut_id = CreateShortcut("app"); |
1285 controller_->SetRefocusURLPatternForTest( | 1283 controller_->SetRefocusURLPatternForTest( |
1286 shortcut_id, GURL("http://www.example.com/path/*")); | 1284 shortcut_id, GURL("http://www.example.com/path/*")); |
1287 std::string url = "http://www.example.com/path/bla"; | 1285 std::string url = "http://www.example.com/path/bla"; |
1288 | 1286 |
1289 int shortcut_index = model_->ItemIndexByID(shortcut_id); | 1287 int shortcut_index = model_->ItemIndexByID(shortcut_id); |
1290 | 1288 |
1291 // Create an application handled browser tab. | 1289 // Create an application handled browser tab. |
(...skipping 12 matching lines...) Expand all Loading... |
1304 NEW_FOREGROUND_TAB, | 1302 NEW_FOREGROUND_TAB, |
1305 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1303 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1306 content::WebContents* content1a = tab_strip->GetActiveWebContents(); | 1304 content::WebContents* content1a = tab_strip->GetActiveWebContents(); |
1307 | 1305 |
1308 // Make sure that the active tab is now our handled tab. | 1306 // Make sure that the active tab is now our handled tab. |
1309 EXPECT_NE(content1a, content1); | 1307 EXPECT_NE(content1a, content1); |
1310 | 1308 |
1311 // The active tab should still be the unnamed tab. Then we switch and reach | 1309 // The active tab should still be the unnamed tab. Then we switch and reach |
1312 // the first app and stay there. | 1310 // the first app and stay there. |
1313 EXPECT_EQ(content1a, tab_strip->GetActiveWebContents()); | 1311 EXPECT_EQ(content1a, tab_strip->GetActiveWebContents()); |
1314 ActivateLauncherItem(shortcut_index); | 1312 ActivateShelfItem(shortcut_index); |
1315 EXPECT_EQ(content1, tab_strip->GetActiveWebContents()); | 1313 EXPECT_EQ(content1, tab_strip->GetActiveWebContents()); |
1316 ActivateLauncherItem(shortcut_index); | 1314 ActivateShelfItem(shortcut_index); |
1317 EXPECT_EQ(content1, tab_strip->GetActiveWebContents()); | 1315 EXPECT_EQ(content1, tab_strip->GetActiveWebContents()); |
1318 | 1316 |
1319 ui_test_utils::NavigateToURLWithDisposition( | 1317 ui_test_utils::NavigateToURLWithDisposition( |
1320 browser(), | 1318 browser(), |
1321 GURL(url), | 1319 GURL(url), |
1322 NEW_FOREGROUND_TAB, | 1320 NEW_FOREGROUND_TAB, |
1323 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1321 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1324 content::WebContents* content2 = tab_strip->GetActiveWebContents(); | 1322 content::WebContents* content2 = tab_strip->GetActiveWebContents(); |
1325 | 1323 |
1326 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); | 1324 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); |
1327 ActivateLauncherItem(shortcut_index); | 1325 ActivateShelfItem(shortcut_index); |
1328 EXPECT_EQ(content1, browser()->tab_strip_model()->GetActiveWebContents()); | 1326 EXPECT_EQ(content1, browser()->tab_strip_model()->GetActiveWebContents()); |
1329 ActivateLauncherItem(shortcut_index); | 1327 ActivateShelfItem(shortcut_index); |
1330 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); | 1328 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); |
1331 } | 1329 } |
1332 | 1330 |
1333 // Check that the keyboard activation of a launcher item tabs properly through | 1331 // Check that the keyboard activation of a launcher item tabs properly through |
1334 // the items at hand. | 1332 // the items at hand. |
1335 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, | 1333 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
1336 AltNumberAppsTabbing) { | 1334 AltNumberAppsTabbing) { |
1337 // First run app. | 1335 // First run app. |
1338 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); | 1336 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); |
1339 ui::BaseWindow* window1 = CreateShellWindow(extension1)->GetBaseWindow(); | 1337 ui::BaseWindow* window1 = CreateShellWindow(extension1)->GetBaseWindow(); |
1340 const ash::LauncherItem& item1 = GetLastLauncherItem(); | 1338 const ash::LauncherItem& item1 = GetLastLauncherItem(); |
1341 ash::LauncherID app_id = item1.id; | 1339 ash::LauncherID app_id = item1.id; |
1342 int app_index = shelf_model()->ItemIndexByID(app_id); | 1340 int app_index = shelf_model()->ItemIndexByID(app_id); |
1343 | 1341 |
1344 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 1342 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
1345 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 1343 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
1346 | 1344 |
1347 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); | 1345 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); |
1348 ui::BaseWindow* window2 = CreateShellWindow(extension2)->GetBaseWindow(); | 1346 ui::BaseWindow* window2 = CreateShellWindow(extension2)->GetBaseWindow(); |
1349 | 1347 |
1350 // By now the browser should be active. Issue Alt keystrokes several times to | 1348 // By now the browser should be active. Issue Alt keystrokes several times to |
1351 // see that we stay on that application. | 1349 // see that we stay on that application. |
1352 EXPECT_TRUE(window2->IsActive()); | 1350 EXPECT_TRUE(window2->IsActive()); |
1353 ActivateLauncherItem(app_index); | 1351 ActivateShelfItem(app_index); |
1354 EXPECT_TRUE(window1->IsActive()); | 1352 EXPECT_TRUE(window1->IsActive()); |
1355 ActivateLauncherItem(app_index); | 1353 ActivateShelfItem(app_index); |
1356 EXPECT_TRUE(window1->IsActive()); | 1354 EXPECT_TRUE(window1->IsActive()); |
1357 | 1355 |
1358 ui::BaseWindow* window1a = CreateShellWindow(extension1)->GetBaseWindow(); | 1356 ui::BaseWindow* window1a = CreateShellWindow(extension1)->GetBaseWindow(); |
1359 | 1357 |
1360 EXPECT_TRUE(window1a->IsActive()); | 1358 EXPECT_TRUE(window1a->IsActive()); |
1361 EXPECT_FALSE(window1->IsActive()); | 1359 EXPECT_FALSE(window1->IsActive()); |
1362 ActivateLauncherItem(app_index); | 1360 ActivateShelfItem(app_index); |
1363 EXPECT_TRUE(window1->IsActive()); | 1361 EXPECT_TRUE(window1->IsActive()); |
1364 ActivateLauncherItem(app_index); | 1362 ActivateShelfItem(app_index); |
1365 EXPECT_TRUE(window1a->IsActive()); | 1363 EXPECT_TRUE(window1a->IsActive()); |
1366 } | 1364 } |
1367 | 1365 |
1368 // Test that we can launch a platform app panel and get a running item. | 1366 // Test that we can launch a platform app panel and get a running item. |
1369 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPanelWindow) { | 1367 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPanelWindow) { |
1370 int item_count = shelf_model()->item_count(); | 1368 int item_count = shelf_model()->item_count(); |
1371 const Extension* extension = LoadAndLaunchPlatformApp("launch"); | 1369 const Extension* extension = LoadAndLaunchPlatformApp("launch"); |
1372 ShellWindow::CreateParams params; | 1370 ShellWindow::CreateParams params; |
1373 params.window_type = ShellWindow::WINDOW_TYPE_PANEL; | 1371 params.window_type = ShellWindow::WINDOW_TYPE_PANEL; |
1374 params.focused = false; | 1372 params.focused = false; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 item_controller->ItemSelected(click_event); | 1408 item_controller->ItemSelected(click_event); |
1411 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 1409 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
1412 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 1410 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
1413 | 1411 |
1414 // Active windows don't show attention. | 1412 // Active windows don't show attention. |
1415 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); | 1413 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); |
1416 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 1414 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
1417 } | 1415 } |
1418 | 1416 |
1419 // Checks that the browser Alt "tabbing" is properly done. | 1417 // Checks that the browser Alt "tabbing" is properly done. |
1420 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestNoDefaultBrowser, | 1418 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
1421 AltNumberBrowserTabbing) { | 1419 AltNumberBrowserTabbing) { |
1422 // Get the number of items in the browser menu. | 1420 // Get the number of items in the browser menu. |
1423 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); | 1421 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); |
1424 // The first activation should create a browser at index 1 (App List @ 0). | 1422 // The first activation should create a browser at index 1 (App List @ 0). |
1425 launcher_->ActivateLauncherItem(1); | 1423 shelf_->ActivateShelfItem(1); |
1426 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1424 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
1427 // A second activation should not create a new instance. | 1425 // A second activation should not create a new instance. |
1428 launcher_->ActivateLauncherItem(1); | 1426 shelf_->ActivateShelfItem(1); |
1429 Browser* browser1 = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); | 1427 Browser* browser1 = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); |
1430 EXPECT_TRUE(browser1); | 1428 EXPECT_TRUE(browser1); |
1431 aura::Window* window1 = browser1->window()->GetNativeWindow(); | 1429 aura::Window* window1 = browser1->window()->GetNativeWindow(); |
1432 Browser* browser2 = CreateBrowser(profile()); | 1430 Browser* browser2 = CreateBrowser(profile()); |
1433 aura::Window* window2 = browser2->window()->GetNativeWindow(); | 1431 aura::Window* window2 = browser2->window()->GetNativeWindow(); |
1434 | 1432 |
1435 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 1433 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
1436 EXPECT_NE(window1, window2); | 1434 EXPECT_NE(window1, window2); |
1437 EXPECT_EQ(window2, ash::wm::GetActiveWindow()); | 1435 EXPECT_EQ(window2, ash::wm::GetActiveWindow()); |
1438 | 1436 |
1439 // Activate multiple times the switcher to see that the windows get activated. | 1437 // Activate multiple times the switcher to see that the windows get activated. |
1440 launcher_->ActivateLauncherItem(1); | 1438 shelf_->ActivateShelfItem(1); |
1441 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); | 1439 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); |
1442 launcher_->ActivateLauncherItem(1); | 1440 shelf_->ActivateShelfItem(1); |
1443 EXPECT_EQ(window2, ash::wm::GetActiveWindow()); | 1441 EXPECT_EQ(window2, ash::wm::GetActiveWindow()); |
1444 | 1442 |
1445 // Create a third browser - make sure that we do not toggle simply between | 1443 // Create a third browser - make sure that we do not toggle simply between |
1446 // two windows. | 1444 // two windows. |
1447 Browser* browser3 = CreateBrowser(profile()); | 1445 Browser* browser3 = CreateBrowser(profile()); |
1448 aura::Window* window3 = browser3->window()->GetNativeWindow(); | 1446 aura::Window* window3 = browser3->window()->GetNativeWindow(); |
1449 | 1447 |
1450 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); | 1448 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); |
1451 EXPECT_NE(window1, window3); | 1449 EXPECT_NE(window1, window3); |
1452 EXPECT_NE(window2, window3); | 1450 EXPECT_NE(window2, window3); |
1453 EXPECT_EQ(window3, ash::wm::GetActiveWindow()); | 1451 EXPECT_EQ(window3, ash::wm::GetActiveWindow()); |
1454 | 1452 |
1455 launcher_->ActivateLauncherItem(1); | 1453 shelf_->ActivateShelfItem(1); |
1456 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); | 1454 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); |
1457 launcher_->ActivateLauncherItem(1); | 1455 shelf_->ActivateShelfItem(1); |
1458 EXPECT_EQ(window2, ash::wm::GetActiveWindow()); | 1456 EXPECT_EQ(window2, ash::wm::GetActiveWindow()); |
1459 launcher_->ActivateLauncherItem(1); | 1457 shelf_->ActivateShelfItem(1); |
1460 EXPECT_EQ(window3, ash::wm::GetActiveWindow()); | 1458 EXPECT_EQ(window3, ash::wm::GetActiveWindow()); |
1461 launcher_->ActivateLauncherItem(1); | 1459 shelf_->ActivateShelfItem(1); |
1462 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); | 1460 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); |
1463 | 1461 |
1464 // Create anther app and make sure that none of our browsers is active. | 1462 // Create anther app and make sure that none of our browsers is active. |
1465 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); | 1463 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); |
1466 EXPECT_NE(window1, ash::wm::GetActiveWindow()); | 1464 EXPECT_NE(window1, ash::wm::GetActiveWindow()); |
1467 EXPECT_NE(window2, ash::wm::GetActiveWindow()); | 1465 EXPECT_NE(window2, ash::wm::GetActiveWindow()); |
1468 | 1466 |
1469 // After activation our browser should be active again. | 1467 // After activation our browser should be active again. |
1470 launcher_->ActivateLauncherItem(1); | 1468 shelf_->ActivateShelfItem(1); |
1471 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); | 1469 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); |
1472 } | 1470 } |
1473 | 1471 |
1474 // Checks that after a session restore, we do not start applications on an | 1472 // Checks that after a session restore, we do not start applications on an |
1475 // activation. | 1473 // activation. |
1476 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ActivateAfterSessionRestore) { | 1474 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ActivateAfterSessionRestore) { |
1477 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1475 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
1478 | 1476 |
1479 // Create a known application. | 1477 // Create a known application. |
1480 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1478 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
1481 | 1479 |
1482 // Create a new browser - without activating it - and load an "app" into it. | 1480 // Create a new browser - without activating it - and load an "app" into it. |
1483 Browser::CreateParams params = | 1481 Browser::CreateParams params = |
1484 Browser::CreateParams(profile(), chrome::GetActiveDesktop()); | 1482 Browser::CreateParams(profile(), chrome::GetActiveDesktop()); |
1485 params.initial_show_state = ui::SHOW_STATE_INACTIVE; | 1483 params.initial_show_state = ui::SHOW_STATE_INACTIVE; |
1486 Browser* browser2 = new Browser(params); | 1484 Browser* browser2 = new Browser(params); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 // was created. | 1522 // was created. |
1525 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 1523 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
1526 EXPECT_EQ(tab_count1, tab_strip->count()); | 1524 EXPECT_EQ(tab_count1, tab_strip->count()); |
1527 EXPECT_EQ(tab_count2, tab_strip2->count()); | 1525 EXPECT_EQ(tab_count2, tab_strip2->count()); |
1528 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), | 1526 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), |
1529 browser2); | 1527 browser2); |
1530 } | 1528 } |
1531 | 1529 |
1532 // Do various drag and drop interaction tests between the application list and | 1530 // Do various drag and drop interaction tests between the application list and |
1533 // the launcher. | 1531 // the launcher. |
1534 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) { | 1532 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DragAndDrop) { |
1535 // Get a number of interfaces we need. | 1533 // Get a number of interfaces we need. |
1536 aura::test::EventGenerator generator( | 1534 aura::test::EventGenerator generator( |
1537 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); | 1535 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); |
1538 ash::test::ShelfViewTestAPI test( | 1536 ash::test::ShelfViewTestAPI test( |
1539 ash::test::LauncherTestAPI(launcher_).shelf_view()); | 1537 ash::test::ShelfTestAPI(shelf_).shelf_view()); |
1540 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); | 1538 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); |
1541 | 1539 |
1542 // There should be two items in our launcher by this time. | 1540 // There should be two items in our launcher by this time. |
1543 EXPECT_EQ(2, model_->item_count()); | 1541 EXPECT_EQ(2, model_->item_count()); |
1544 EXPECT_FALSE(service->IsAppListVisible()); | 1542 EXPECT_FALSE(service->IsAppListVisible()); |
1545 | 1543 |
1546 // Open the app list menu and check that the drag and drop host was set. | 1544 // Open the app list menu and check that the drag and drop host was set. |
1547 gfx::Rect app_list_bounds = | 1545 gfx::Rect app_list_bounds = |
1548 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); | 1546 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); |
1549 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), | 1547 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), |
(...skipping 19 matching lines...) Expand all Loading... |
1569 // Get over item #1 of the application list and press the mouse button. | 1567 // Get over item #1 of the application list and press the mouse button. |
1570 views::View* item1 = vm_grid->view_at(1); | 1568 views::View* item1 = vm_grid->view_at(1); |
1571 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); | 1569 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); |
1572 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1570 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
1573 bounds_grid_1.CenterPoint().y()); | 1571 bounds_grid_1.CenterPoint().y()); |
1574 base::MessageLoop::current()->RunUntilIdle(); | 1572 base::MessageLoop::current()->RunUntilIdle(); |
1575 generator.PressLeftButton(); | 1573 generator.PressLeftButton(); |
1576 | 1574 |
1577 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1575 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1578 | 1576 |
1579 // Drag the item into the launcher and check that a new item gets created. | 1577 // Drag the item into the shelf and check that a new item gets created. |
1580 const views::ViewModel* vm_launcher = | 1578 const views::ViewModel* vm_shelf = test.shelf_view()->view_model_for_test(); |
1581 test.shelf_view()->view_model_for_test(); | 1579 views::View* shelf1 = vm_shelf->view_at(1); |
1582 views::View* launcher1 = vm_launcher->view_at(1); | 1580 gfx::Rect bounds_shelf_1 = shelf1->GetBoundsInScreen(); |
1583 gfx::Rect bounds_launcher_1 = launcher1->GetBoundsInScreen(); | 1581 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), |
1584 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(), | 1582 bounds_shelf_1.CenterPoint().y()); |
1585 bounds_launcher_1.CenterPoint().y()); | |
1586 base::MessageLoop::current()->RunUntilIdle(); | 1583 base::MessageLoop::current()->RunUntilIdle(); |
1587 | 1584 |
1588 // Check that a new item got created. | 1585 // Check that a new item got created. |
1589 EXPECT_EQ(3, model_->item_count()); | 1586 EXPECT_EQ(3, model_->item_count()); |
1590 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1587 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1591 | 1588 |
1592 // Move it where the item originally was and check that it disappears again. | 1589 // Move it where the item originally was and check that it disappears again. |
1593 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1590 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
1594 bounds_grid_1.CenterPoint().y()); | 1591 bounds_grid_1.CenterPoint().y()); |
1595 base::MessageLoop::current()->RunUntilIdle(); | 1592 base::MessageLoop::current()->RunUntilIdle(); |
1596 EXPECT_EQ(2, model_->item_count()); | 1593 EXPECT_EQ(2, model_->item_count()); |
1597 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1594 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1598 | 1595 |
1599 // Dropping it should keep the launcher as it originally was. | 1596 // Dropping it should keep the launcher as it originally was. |
1600 generator.ReleaseLeftButton(); | 1597 generator.ReleaseLeftButton(); |
1601 base::MessageLoop::current()->RunUntilIdle(); | 1598 base::MessageLoop::current()->RunUntilIdle(); |
1602 EXPECT_EQ(2, model_->item_count()); | 1599 EXPECT_EQ(2, model_->item_count()); |
1603 // There are a few animations which need finishing before we can continue. | 1600 // There are a few animations which need finishing before we can continue. |
1604 test.RunMessageLoopUntilAnimationsDone(); | 1601 test.RunMessageLoopUntilAnimationsDone(); |
1605 // Move the mouse outside of the launcher. | 1602 // Move the mouse outside of the launcher. |
1606 generator.MoveMouseTo(0, 0); | 1603 generator.MoveMouseTo(0, 0); |
1607 | 1604 |
1608 // Test #2: Check that the unknown item dropped into the launcher will | 1605 // Test #2: Check that the unknown item dropped into the launcher will |
1609 // create a new item. | 1606 // create a new item. |
1610 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1607 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
1611 bounds_grid_1.CenterPoint().y()); | 1608 bounds_grid_1.CenterPoint().y()); |
1612 generator.PressLeftButton(); | 1609 generator.PressLeftButton(); |
1613 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(), | 1610 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), |
1614 bounds_launcher_1.CenterPoint().y()); | 1611 bounds_shelf_1.CenterPoint().y()); |
1615 base::MessageLoop::current()->RunUntilIdle(); | 1612 base::MessageLoop::current()->RunUntilIdle(); |
1616 EXPECT_EQ(3, model_->item_count()); | 1613 EXPECT_EQ(3, model_->item_count()); |
1617 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1614 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1618 generator.ReleaseLeftButton(); | 1615 generator.ReleaseLeftButton(); |
1619 base::MessageLoop::current()->RunUntilIdle(); | 1616 base::MessageLoop::current()->RunUntilIdle(); |
1620 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1617 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1621 EXPECT_EQ(3, model_->item_count()); // It should be still there. | 1618 EXPECT_EQ(3, model_->item_count()); // It should be still there. |
1622 test.RunMessageLoopUntilAnimationsDone(); | 1619 test.RunMessageLoopUntilAnimationsDone(); |
1623 | 1620 |
1624 // Test #3: Check that the now known item dropped into the launcher will | 1621 // Test #3: Check that the now known item dropped into the launcher will |
1625 // not create a new item. | 1622 // not create a new item. |
1626 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1623 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
1627 bounds_grid_1.CenterPoint().y()); | 1624 bounds_grid_1.CenterPoint().y()); |
1628 generator.PressLeftButton(); | 1625 generator.PressLeftButton(); |
1629 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(), | 1626 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), |
1630 bounds_launcher_1.CenterPoint().y()); | 1627 bounds_shelf_1.CenterPoint().y()); |
1631 base::MessageLoop::current()->RunUntilIdle(); | 1628 base::MessageLoop::current()->RunUntilIdle(); |
1632 EXPECT_EQ(3, model_->item_count()); // No new item got added. | 1629 EXPECT_EQ(3, model_->item_count()); // No new item got added. |
1633 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1630 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1634 generator.ReleaseLeftButton(); | 1631 generator.ReleaseLeftButton(); |
1635 base::MessageLoop::current()->RunUntilIdle(); | 1632 base::MessageLoop::current()->RunUntilIdle(); |
1636 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1633 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1637 EXPECT_EQ(3, model_->item_count()); // And it remains that way. | 1634 EXPECT_EQ(3, model_->item_count()); // And it remains that way. |
1638 | 1635 |
1639 // Test #4: Check that by pressing ESC the operation gets cancelled. | 1636 // Test #4: Check that by pressing ESC the operation gets cancelled. |
1640 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1637 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
1641 bounds_grid_1.CenterPoint().y()); | 1638 bounds_grid_1.CenterPoint().y()); |
1642 generator.PressLeftButton(); | 1639 generator.PressLeftButton(); |
1643 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(), | 1640 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), |
1644 bounds_launcher_1.CenterPoint().y()); | 1641 bounds_shelf_1.CenterPoint().y()); |
1645 base::MessageLoop::current()->RunUntilIdle(); | 1642 base::MessageLoop::current()->RunUntilIdle(); |
1646 // Issue an ESC and see that the operation gets cancelled. | 1643 // Issue an ESC and see that the operation gets cancelled. |
1647 generator.PressKey(ui::VKEY_ESCAPE, 0); | 1644 generator.PressKey(ui::VKEY_ESCAPE, 0); |
1648 generator.ReleaseKey(ui::VKEY_ESCAPE, 0); | 1645 generator.ReleaseKey(ui::VKEY_ESCAPE, 0); |
1649 EXPECT_FALSE(grid_view->dragging()); | 1646 EXPECT_FALSE(grid_view->dragging()); |
1650 EXPECT_FALSE(grid_view->has_dragged_view()); | 1647 EXPECT_FALSE(grid_view->has_dragged_view()); |
1651 generator.ReleaseLeftButton(); | 1648 generator.ReleaseLeftButton(); |
1652 } | 1649 } |
1653 | 1650 |
1654 #if !defined(OS_WIN) | 1651 #if !defined(OS_WIN) |
1655 // Used to test drag & drop an item between app list and shelf with multi | 1652 // Used to test drag & drop an item between app list and shelf with multi |
1656 // display environment. | 1653 // display environment. |
1657 class LauncherAppBrowserTestWithMultiMonitor | 1654 class ShelfAppBrowserTestWithMultiMonitor |
1658 : public LauncherAppBrowserTestNoDefaultBrowser { | 1655 : public ShelfAppBrowserTestNoDefaultBrowser { |
1659 protected: | 1656 protected: |
1660 LauncherAppBrowserTestWithMultiMonitor() {} | 1657 ShelfAppBrowserTestWithMultiMonitor() {} |
1661 virtual ~LauncherAppBrowserTestWithMultiMonitor() {} | 1658 virtual ~ShelfAppBrowserTestWithMultiMonitor() {} |
1662 | 1659 |
1663 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 1660 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
1664 LauncherAppBrowserTestNoDefaultBrowser::SetUpCommandLine(command_line); | 1661 ShelfAppBrowserTestNoDefaultBrowser::SetUpCommandLine(command_line); |
1665 command_line->AppendSwitchASCII("ash-host-window-bounds", | 1662 command_line->AppendSwitchASCII("ash-host-window-bounds", |
1666 "800x600,801+0-800x600"); | 1663 "800x600,801+0-800x600"); |
1667 } | 1664 } |
1668 | 1665 |
1669 private: | 1666 private: |
1670 | 1667 |
1671 DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserTestWithMultiMonitor); | 1668 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestWithMultiMonitor); |
1672 }; | 1669 }; |
1673 | 1670 |
1674 // Do basic drag and drop interaction tests between the application list and | 1671 // Do basic drag and drop interaction tests between the application list and |
1675 // the launcher in the secondary monitor. | 1672 // the launcher in the secondary monitor. |
1676 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestWithMultiMonitor, | 1673 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestWithMultiMonitor, |
1677 BasicDragAndDrop) { | 1674 BasicDragAndDrop) { |
1678 // Get a number of interfaces we need. | 1675 // Get a number of interfaces we need. |
1679 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U); | 1676 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U); |
1680 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1]; | 1677 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1]; |
1681 ash::Launcher* secondary_launcher = | 1678 ash::Shelf* secondary_shelf = ash::Shelf::ForWindow(secondary_root_window); |
1682 ash::Launcher::ForWindow(secondary_root_window); | |
1683 | 1679 |
1684 aura::test::EventGenerator generator(secondary_root_window, gfx::Point()); | 1680 aura::test::EventGenerator generator(secondary_root_window, gfx::Point()); |
1685 ash::test::ShelfViewTestAPI test( | 1681 ash::test::ShelfViewTestAPI test( |
1686 ash::test::LauncherTestAPI(secondary_launcher).shelf_view()); | 1682 ash::test::ShelfTestAPI(secondary_shelf).shelf_view()); |
1687 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); | 1683 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); |
1688 | 1684 |
1689 // There should be two items in our launcher by this time. | 1685 // There should be two items in our shelf by this time. |
1690 EXPECT_EQ(2, model_->item_count()); | 1686 EXPECT_EQ(2, model_->item_count()); |
1691 EXPECT_FALSE(service->IsAppListVisible()); | 1687 EXPECT_FALSE(service->IsAppListVisible()); |
1692 | 1688 |
1693 // Open the app list menu and check that the drag and drop host was set. | 1689 // Open the app list menu and check that the drag and drop host was set. |
1694 gfx::Rect app_list_bounds = | 1690 gfx::Rect app_list_bounds = |
1695 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); | 1691 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); |
1696 gfx::Display display = | 1692 gfx::Display display = |
1697 ash::Shell::GetScreen()->GetDisplayNearestWindow(secondary_root_window); | 1693 ash::Shell::GetScreen()->GetDisplayNearestWindow(secondary_root_window); |
1698 const gfx::Point& origin = display.bounds().origin(); | 1694 const gfx::Point& origin = display.bounds().origin(); |
1699 app_list_bounds.Offset(-origin.x(), -origin.y()); | 1695 app_list_bounds.Offset(-origin.x(), -origin.y()); |
1700 | 1696 |
1701 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), | 1697 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), |
1702 app_list_bounds.CenterPoint().y()); | 1698 app_list_bounds.CenterPoint().y()); |
1703 base::MessageLoop::current()->RunUntilIdle(); | 1699 base::MessageLoop::current()->RunUntilIdle(); |
1704 generator.ClickLeftButton(); | 1700 generator.ClickLeftButton(); |
1705 | 1701 |
1706 EXPECT_TRUE(service->IsAppListVisible()); | 1702 EXPECT_TRUE(service->IsAppListVisible()); |
1707 app_list::AppsGridView* grid_view = | 1703 app_list::AppsGridView* grid_view = |
1708 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). | 1704 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). |
1709 GetRootGridView(); | 1705 GetRootGridView(); |
1710 ASSERT_TRUE(grid_view); | 1706 ASSERT_TRUE(grid_view); |
1711 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); | 1707 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); |
1712 | 1708 |
1713 // There should be 2 items in our application list. | 1709 // There should be 2 items in our application list. |
1714 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); | 1710 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); |
1715 EXPECT_EQ(2, vm_grid->view_size()); | 1711 EXPECT_EQ(2, vm_grid->view_size()); |
1716 | 1712 |
1717 // Drag an app list item which does not exist yet in the launcher. | 1713 // Drag an app list item which does not exist yet in the shelf. |
1718 // Keeping it dragged, see that a new item gets created. | 1714 // Keeping it dragged, see that a new item gets created. |
1719 // Continuing to drag it out should remove it again. | 1715 // Continuing to drag it out should remove it again. |
1720 | 1716 |
1721 // Get over item #1 of the application list and press the mouse button. | 1717 // Get over item #1 of the application list and press the mouse button. |
1722 views::View* item1 = vm_grid->view_at(1); | 1718 views::View* item1 = vm_grid->view_at(1); |
1723 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); | 1719 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); |
1724 bounds_grid_1.Offset(-origin.x(), -origin.y()); | 1720 bounds_grid_1.Offset(-origin.x(), -origin.y()); |
1725 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1721 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
1726 bounds_grid_1.CenterPoint().y()); | 1722 bounds_grid_1.CenterPoint().y()); |
1727 base::MessageLoop::current()->RunUntilIdle(); | 1723 base::MessageLoop::current()->RunUntilIdle(); |
1728 generator.PressLeftButton(); | 1724 generator.PressLeftButton(); |
1729 | 1725 |
1730 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1726 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1731 | 1727 |
1732 // Drag the item into the launcher and check that a new item gets created. | 1728 // Drag the item into the shelf and check that a new item gets created. |
1733 const views::ViewModel* vm_launcher = | 1729 const views::ViewModel* vm_shelf = test.shelf_view()->view_model_for_test(); |
1734 test.shelf_view()->view_model_for_test(); | 1730 views::View* shelf1 = vm_shelf->view_at(1); |
1735 views::View* launcher1 = vm_launcher->view_at(1); | 1731 gfx::Rect bounds_shelf_1 = shelf1->GetBoundsInScreen(); |
1736 gfx::Rect bounds_launcher_1 = launcher1->GetBoundsInScreen(); | 1732 bounds_shelf_1.Offset(-origin.x(), -origin.y()); |
1737 bounds_launcher_1.Offset(-origin.x(), -origin.y()); | 1733 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), |
1738 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(), | 1734 bounds_shelf_1.CenterPoint().y()); |
1739 bounds_launcher_1.CenterPoint().y()); | |
1740 base::MessageLoop::current()->RunUntilIdle(); | 1735 base::MessageLoop::current()->RunUntilIdle(); |
1741 | 1736 |
1742 // Check that a new item got created. | 1737 // Check that a new item got created. |
1743 EXPECT_EQ(3, model_->item_count()); | 1738 EXPECT_EQ(3, model_->item_count()); |
1744 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1739 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1745 | 1740 |
1746 // Move it where the item originally was and check that it disappears again. | 1741 // Move it where the item originally was and check that it disappears again. |
1747 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1742 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
1748 bounds_grid_1.CenterPoint().y()); | 1743 bounds_grid_1.CenterPoint().y()); |
1749 base::MessageLoop::current()->RunUntilIdle(); | 1744 base::MessageLoop::current()->RunUntilIdle(); |
1750 EXPECT_EQ(2, model_->item_count()); | 1745 EXPECT_EQ(2, model_->item_count()); |
1751 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1746 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
1752 | 1747 |
1753 // Dropping it should keep the launcher as it originally was. | 1748 // Dropping it should keep the shelf as it originally was. |
1754 generator.ReleaseLeftButton(); | 1749 generator.ReleaseLeftButton(); |
1755 base::MessageLoop::current()->RunUntilIdle(); | 1750 base::MessageLoop::current()->RunUntilIdle(); |
1756 EXPECT_EQ(2, model_->item_count()); | 1751 EXPECT_EQ(2, model_->item_count()); |
1757 } | 1752 } |
1758 #endif | 1753 #endif |
1759 | 1754 |
1760 // Do tests for removal of items from the shelf by dragging. | 1755 // Do tests for removal of items from the shelf by dragging. |
1761 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragOffShelf) { | 1756 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DragOffShelf) { |
1762 aura::test::EventGenerator generator( | 1757 aura::test::EventGenerator generator( |
1763 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); | 1758 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); |
1764 ash::test::ShelfViewTestAPI test( | 1759 ash::test::ShelfViewTestAPI test( |
1765 ash::test::LauncherTestAPI(launcher_).shelf_view()); | 1760 ash::test::ShelfTestAPI(shelf_).shelf_view()); |
1766 test.SetAnimationDuration(1); // Speed up animations for test. | 1761 test.SetAnimationDuration(1); // Speed up animations for test. |
1767 // Create a known application and check that we have 3 items in the launcher. | 1762 // Create a known application and check that we have 3 items in the shelf. |
1768 CreateShortcut("app1"); | 1763 CreateShortcut("app1"); |
1769 test.RunMessageLoopUntilAnimationsDone(); | 1764 test.RunMessageLoopUntilAnimationsDone(); |
1770 EXPECT_EQ(3, model_->item_count()); | 1765 EXPECT_EQ(3, model_->item_count()); |
1771 | 1766 |
1772 // Test #1: Ripping out the browser item should not change anything. | 1767 // Test #1: Ripping out the browser item should not change anything. |
1773 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); | 1768 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); |
1774 EXPECT_LE(0, browser_index); | 1769 EXPECT_LE(0, browser_index); |
1775 RipOffItemIndex(browser_index, &generator, &test, RIP_OFF_ITEM); | 1770 RipOffItemIndex(browser_index, &generator, &test, RIP_OFF_ITEM); |
1776 // => It should not have been removed and the location should be unchanged. | 1771 // => It should not have been removed and the location should be unchanged. |
1777 EXPECT_EQ(3, model_->item_count()); | 1772 EXPECT_EQ(3, model_->item_count()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 ASSERT_LT(items_added, 10000); | 1833 ASSERT_LT(items_added, 10000); |
1839 } | 1834 } |
1840 // Make one more item after creating a overflow button. | 1835 // Make one more item after creating a overflow button. |
1841 std::string fake_app_id = base::StringPrintf("fake_app_%d", items_added); | 1836 std::string fake_app_id = base::StringPrintf("fake_app_%d", items_added); |
1842 PinFakeApp(fake_app_id); | 1837 PinFakeApp(fake_app_id); |
1843 test.RunMessageLoopUntilAnimationsDone(); | 1838 test.RunMessageLoopUntilAnimationsDone(); |
1844 | 1839 |
1845 int total_count = model_->item_count(); | 1840 int total_count = model_->item_count(); |
1846 app_index = GetIndexOfShelfItemType(ash::TYPE_APP_SHORTCUT); | 1841 app_index = GetIndexOfShelfItemType(ash::TYPE_APP_SHORTCUT); |
1847 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM); | 1842 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM); |
1848 // When an item is ripped off from the launcher that has overflow button | 1843 // When an item is ripped off from the shelf that has overflow button |
1849 // (see crbug.com/3050787), it was hidden accidentally and was then | 1844 // (see crbug.com/3050787), it was hidden accidentally and was then |
1850 // suppressing any further events. If handled correctly the operation will | 1845 // suppressing any further events. If handled correctly the operation will |
1851 // however correctly done and the item will get removed (as well as the | 1846 // however correctly done and the item will get removed (as well as the |
1852 // overflow button). | 1847 // overflow button). |
1853 EXPECT_EQ(total_count - 1, model_->item_count()); | 1848 EXPECT_EQ(total_count - 1, model_->item_count()); |
1854 EXPECT_TRUE(test.IsOverflowButtonVisible()); | 1849 EXPECT_TRUE(test.IsOverflowButtonVisible()); |
1855 | 1850 |
1856 // Rip off again and the overflow button should has disappeared. | 1851 // Rip off again and the overflow button should has disappeared. |
1857 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM); | 1852 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM); |
1858 EXPECT_EQ(total_count - 2, model_->item_count()); | 1853 EXPECT_EQ(total_count - 2, model_->item_count()); |
1859 EXPECT_FALSE(test.IsOverflowButtonVisible()); | 1854 EXPECT_FALSE(test.IsOverflowButtonVisible()); |
1860 } | 1855 } |
1861 | 1856 |
1862 // Check that clicking on an app launcher item launches a new browser. | 1857 // Check that clicking on an app shelf item launches a new browser. |
1863 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ClickItem) { | 1858 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ClickItem) { |
1864 // Get a number of interfaces we need. | 1859 // Get a number of interfaces we need. |
1865 aura::test::EventGenerator generator( | 1860 aura::test::EventGenerator generator( |
1866 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); | 1861 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); |
1867 ash::test::ShelfViewTestAPI test( | 1862 ash::test::ShelfViewTestAPI test( |
1868 ash::test::LauncherTestAPI(launcher_).shelf_view()); | 1863 ash::test::ShelfTestAPI(shelf_).shelf_view()); |
1869 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); | 1864 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); |
1870 // There should be two items in our launcher by this time. | 1865 // There should be two items in our shelf by this time. |
1871 EXPECT_EQ(2, model_->item_count()); | 1866 EXPECT_EQ(2, model_->item_count()); |
1872 EXPECT_FALSE(service->IsAppListVisible()); | 1867 EXPECT_FALSE(service->IsAppListVisible()); |
1873 | 1868 |
1874 // Open the app list menu and check that the drag and drop host was set. | 1869 // Open the app list menu and check that the drag and drop host was set. |
1875 gfx::Rect app_list_bounds = | 1870 gfx::Rect app_list_bounds = |
1876 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); | 1871 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); |
1877 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), | 1872 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), |
1878 app_list_bounds.CenterPoint().y()); | 1873 app_list_bounds.CenterPoint().y()); |
1879 generator.ClickLeftButton(); | 1874 generator.ClickLeftButton(); |
1880 base::MessageLoop::current()->RunUntilIdle(); | 1875 base::MessageLoop::current()->RunUntilIdle(); |
(...skipping 10 matching lines...) Expand all Loading... |
1891 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1886 TabStripModel* tab_strip = browser()->tab_strip_model(); |
1892 int tab_count = tab_strip->count(); | 1887 int tab_count = tab_strip->count(); |
1893 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1888 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
1894 bounds_grid_1.CenterPoint().y()); | 1889 bounds_grid_1.CenterPoint().y()); |
1895 generator.ClickLeftButton(); | 1890 generator.ClickLeftButton(); |
1896 base::MessageLoop::current()->RunUntilIdle(); | 1891 base::MessageLoop::current()->RunUntilIdle(); |
1897 EXPECT_EQ(tab_count + 1, tab_strip->count()); | 1892 EXPECT_EQ(tab_count + 1, tab_strip->count()); |
1898 } | 1893 } |
1899 | 1894 |
1900 // Check LauncherItemController of Browser Shortcut functionality. | 1895 // Check LauncherItemController of Browser Shortcut functionality. |
1901 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestNoDefaultBrowser, | 1896 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
1902 BrowserShortcutLauncherItemController) { | 1897 BrowserShortcutLauncherItemController) { |
1903 LauncherItemController* item_controller = | 1898 LauncherItemController* item_controller = |
1904 controller_->GetBrowserShortcutLauncherItemController(); | 1899 controller_->GetBrowserShortcutLauncherItemController(); |
1905 | 1900 |
1906 // Get the number of browsers. | 1901 // Get the number of browsers. |
1907 size_t running_browser = chrome::GetTotalBrowserCount(); | 1902 size_t running_browser = chrome::GetTotalBrowserCount(); |
1908 EXPECT_EQ(0u, running_browser); | 1903 EXPECT_EQ(0u, running_browser); |
1909 EXPECT_FALSE(item_controller->IsOpen()); | 1904 EXPECT_FALSE(item_controller->IsOpen()); |
1910 | 1905 |
1911 // Activate. This creates new browser | 1906 // Activate. This creates new browser |
1912 item_controller->Activate(ash::LAUNCH_FROM_UNKNOWN); | 1907 item_controller->Activate(ash::LAUNCH_FROM_UNKNOWN); |
(...skipping 10 matching lines...) Expand all Loading... |
1923 // Activate again. This doesn't create new browser. | 1918 // Activate again. This doesn't create new browser. |
1924 // It activates window. | 1919 // It activates window. |
1925 item_controller->Activate(ash::LAUNCH_FROM_UNKNOWN); | 1920 item_controller->Activate(ash::LAUNCH_FROM_UNKNOWN); |
1926 running_browser = chrome::GetTotalBrowserCount(); | 1921 running_browser = chrome::GetTotalBrowserCount(); |
1927 EXPECT_EQ(1u, running_browser); | 1922 EXPECT_EQ(1u, running_browser); |
1928 EXPECT_TRUE(item_controller->IsOpen()); | 1923 EXPECT_TRUE(item_controller->IsOpen()); |
1929 EXPECT_FALSE(window_state->IsMinimized()); | 1924 EXPECT_FALSE(window_state->IsMinimized()); |
1930 } | 1925 } |
1931 | 1926 |
1932 // Check that GetLauncherIDForWindow() returns |LauncherID| of the active tab. | 1927 // Check that GetLauncherIDForWindow() returns |LauncherID| of the active tab. |
1933 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MatchingLauncherIDandActiveTab) { | 1928 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingLauncherIDandActiveTab) { |
1934 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1929 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
1935 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 1930 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
1936 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 1931 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
1937 EXPECT_EQ(2, model_->item_count()); | 1932 EXPECT_EQ(2, model_->item_count()); |
1938 | 1933 |
1939 aura::Window* window = browser()->window()->GetNativeWindow(); | 1934 aura::Window* window = browser()->window()->GetNativeWindow(); |
1940 | 1935 |
1941 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); | 1936 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); |
1942 ash::LauncherID browser_id = model_->items()[browser_index].id; | 1937 ash::LauncherID browser_id = model_->items()[browser_index].id; |
1943 EXPECT_EQ(browser_id, ash::GetLauncherIDForWindow(window)); | 1938 EXPECT_EQ(browser_id, ash::GetLauncherIDForWindow(window)); |
1944 | 1939 |
1945 ash::LauncherID app_id = CreateShortcut("app1"); | 1940 ash::LauncherID app_id = CreateShortcut("app1"); |
1946 EXPECT_EQ(3, model_->item_count()); | 1941 EXPECT_EQ(3, model_->item_count()); |
1947 | 1942 |
1948 // Creates a new tab for "app1" and checks that GetLauncherIDForWindow() | 1943 // Creates a new tab for "app1" and checks that GetLauncherIDForWindow() |
1949 // returns |LauncherID| of "app1". | 1944 // returns |LauncherID| of "app1". |
1950 ActivateLauncherItem(model_->ItemIndexByID(app_id)); | 1945 ActivateShelfItem(model_->ItemIndexByID(app_id)); |
1951 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 1946 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
1952 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 1947 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
1953 EXPECT_EQ(app_id, ash::GetLauncherIDForWindow(window)); | 1948 EXPECT_EQ(app_id, ash::GetLauncherIDForWindow(window)); |
1954 | 1949 |
1955 // Makes tab at index 0(NTP) as an active tab and checks that | 1950 // Makes tab at index 0(NTP) as an active tab and checks that |
1956 // GetLauncherIDForWindow() returns |LauncherID| of browser shortcut. | 1951 // GetLauncherIDForWindow() returns |LauncherID| of browser shortcut. |
1957 browser()->tab_strip_model()->ActivateTabAt(0, false); | 1952 browser()->tab_strip_model()->ActivateTabAt(0, false); |
1958 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 1953 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
1959 EXPECT_EQ(browser_id, ash::GetLauncherIDForWindow(window)); | 1954 EXPECT_EQ(browser_id, ash::GetLauncherIDForWindow(window)); |
1960 } | 1955 } |
1961 | 1956 |
1962 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, OverflowBubble) { | 1957 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, OverflowBubble) { |
1963 // Make sure to have a browser window | 1958 // Make sure to have a browser window |
1964 chrome::NewTab(browser()); | 1959 chrome::NewTab(browser()); |
1965 | 1960 |
1966 // No overflow yet. | 1961 // No overflow yet. |
1967 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); | 1962 EXPECT_FALSE(shelf_->IsShowingOverflowBubble()); |
1968 | 1963 |
1969 ash::test::ShelfViewTestAPI test( | 1964 ash::test::ShelfViewTestAPI test( |
1970 ash::test::LauncherTestAPI(launcher_).shelf_view()); | 1965 ash::test::ShelfTestAPI(shelf_).shelf_view()); |
1971 | 1966 |
1972 int items_added = 0; | 1967 int items_added = 0; |
1973 while (!test.IsOverflowButtonVisible()) { | 1968 while (!test.IsOverflowButtonVisible()) { |
1974 std::string fake_app_id = base::StringPrintf("fake_app_%d", items_added); | 1969 std::string fake_app_id = base::StringPrintf("fake_app_%d", items_added); |
1975 PinFakeApp(fake_app_id); | 1970 PinFakeApp(fake_app_id); |
1976 | 1971 |
1977 ++items_added; | 1972 ++items_added; |
1978 ASSERT_LT(items_added, 10000); | 1973 ASSERT_LT(items_added, 10000); |
1979 } | 1974 } |
1980 | 1975 |
1981 // Now show overflow bubble. | 1976 // Now show overflow bubble. |
1982 test.ShowOverflowBubble(); | 1977 test.ShowOverflowBubble(); |
1983 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); | 1978 EXPECT_TRUE(shelf_->IsShowingOverflowBubble()); |
1984 | 1979 |
1985 // Unpin first pinned app and there should be no crash. | 1980 // Unpin first pinned app and there should be no crash. |
1986 controller_->UnpinAppWithID(std::string("fake_app_0")); | 1981 controller_->UnpinAppWithID(std::string("fake_app_0")); |
1987 | 1982 |
1988 test.RunMessageLoopUntilAnimationsDone(); | 1983 test.RunMessageLoopUntilAnimationsDone(); |
1989 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); | 1984 EXPECT_FALSE(shelf_->IsShowingOverflowBubble()); |
1990 } | 1985 } |
1991 | 1986 |
1992 // Check that a windowed V1 application can navigate away from its domain, but | 1987 // Check that a windowed V1 application can navigate away from its domain, but |
1993 // still gets detected properly. | 1988 // still gets detected properly. |
1994 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, V1AppNavigation) { | 1989 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, V1AppNavigation) { |
1995 // We assume that the web store is always there (which it apparently is). | 1990 // We assume that the web store is always there (which it apparently is). |
1996 controller_->PinAppWithID(extension_misc::kWebStoreAppId); | 1991 controller_->PinAppWithID(extension_misc::kWebStoreAppId); |
1997 ash::LauncherID id = controller_->GetLauncherIDForAppID( | 1992 ash::LauncherID id = controller_->GetLauncherIDForAppID( |
1998 extension_misc::kWebStoreAppId); | 1993 extension_misc::kWebStoreAppId); |
1999 ASSERT_NE(0, id); | 1994 ASSERT_NE(0, id); |
2000 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); | 1995 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); |
2001 | 1996 |
2002 // Create a windowed application. | 1997 // Create a windowed application. |
2003 AppLaunchParams params( | 1998 AppLaunchParams params( |
2004 profile(), | 1999 profile(), |
(...skipping 23 matching lines...) Expand all Loading... |
2028 GURL("http://www.foo.com/bar.html")); | 2023 GURL("http://www.foo.com/bar.html")); |
2029 // Make sure the navigation was entirely performed. | 2024 // Make sure the navigation was entirely performed. |
2030 base::MessageLoop::current()->RunUntilIdle(); | 2025 base::MessageLoop::current()->RunUntilIdle(); |
2031 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); | 2026 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); |
2032 app_browser->tab_strip_model()->CloseWebContentsAt(0, | 2027 app_browser->tab_strip_model()->CloseWebContentsAt(0, |
2033 TabStripModel::CLOSE_NONE); | 2028 TabStripModel::CLOSE_NONE); |
2034 // Make sure that the app is really gone. | 2029 // Make sure that the app is really gone. |
2035 base::MessageLoop::current()->RunUntilIdle(); | 2030 base::MessageLoop::current()->RunUntilIdle(); |
2036 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); | 2031 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); |
2037 } | 2032 } |
OLD | NEW |