| 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/native_app_window.h" | 7 #include "apps/native_app_window.h" |
| 8 #include "apps/shell_window.h" | 8 #include "apps/shell_window.h" |
| 9 #include "apps/shell_window_registry.h" | 9 #include "apps/shell_window_registry.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 ui_test_utils::NavigateToURL( | 1026 ui_test_utils::NavigateToURL( |
| 1027 browser(), GURL("http://www.example.com/path1/foo.html")); | 1027 browser(), GURL("http://www.example.com/path1/foo.html")); |
| 1028 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 1028 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 // Confirm that a tab can be moved between browsers while maintaining the | 1031 // Confirm that a tab can be moved between browsers while maintaining the |
| 1032 // correct running state. | 1032 // correct running state. |
| 1033 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, TabDragAndDrop) { | 1033 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, TabDragAndDrop) { |
| 1034 TabStripModel* tab_strip_model1 = browser()->tab_strip_model(); | 1034 TabStripModel* tab_strip_model1 = browser()->tab_strip_model(); |
| 1035 EXPECT_EQ(1, tab_strip_model1->count()); | 1035 EXPECT_EQ(1, tab_strip_model1->count()); |
| 1036 int browser_index = ash::GetBrowserItemIndex(*model_); | 1036 int browser_index = |
| 1037 ash::GetLauncherItemIndexForType(ash::TYPE_BROWSER_SHORTCUT, *model_); |
| 1037 EXPECT_TRUE(browser_index >= 0); | 1038 EXPECT_TRUE(browser_index >= 0); |
| 1038 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1039 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 1039 | 1040 |
| 1040 // Create a shortcut for app1. | 1041 // Create a shortcut for app1. |
| 1041 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1042 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
| 1042 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); | 1043 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); |
| 1043 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 1044 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
| 1044 | 1045 |
| 1045 // Activate app1 and check its item status. | 1046 // Activate app1 and check its item status. |
| 1046 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 1047 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 WebContents* second_tab = tab_strip->GetActiveWebContents(); | 1170 WebContents* second_tab = tab_strip->GetActiveWebContents(); |
| 1170 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1171 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 1171 EXPECT_NE(first_tab, second_tab); | 1172 EXPECT_NE(first_tab, second_tab); |
| 1172 EXPECT_EQ(tab_strip->GetActiveWebContents(), second_tab); | 1173 EXPECT_EQ(tab_strip->GetActiveWebContents(), second_tab); |
| 1173 } | 1174 } |
| 1174 | 1175 |
| 1175 // Check the launcher activation state for applications and browser. | 1176 // Check the launcher activation state for applications and browser. |
| 1176 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ActivationStateCheck) { | 1177 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ActivationStateCheck) { |
| 1177 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1178 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1178 // Get the browser item index | 1179 // Get the browser item index |
| 1179 int browser_index = ash::GetBrowserItemIndex(*controller_->model()); | 1180 int browser_index = |
| 1181 ash::GetLauncherItemIndexForType(ash::TYPE_BROWSER_SHORTCUT, *model_); |
| 1180 EXPECT_TRUE(browser_index >= 0); | 1182 EXPECT_TRUE(browser_index >= 0); |
| 1181 | 1183 |
| 1182 // Even though we are just comming up, the browser should be active. | 1184 // Even though we are just comming up, the browser should be active. |
| 1183 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); | 1185 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); |
| 1184 | 1186 |
| 1185 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 1187 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
| 1186 controller_->SetRefocusURLPatternForTest( | 1188 controller_->SetRefocusURLPatternForTest( |
| 1187 shortcut_id, GURL("http://www.example.com/path1/*")); | 1189 shortcut_id, GURL("http://www.example.com/path1/*")); |
| 1188 | 1190 |
| 1189 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1191 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 | 1833 |
| 1832 // Check that GetIDByWindow() returns |LauncherID| of the active tab. | 1834 // Check that GetIDByWindow() returns |LauncherID| of the active tab. |
| 1833 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MatchingLauncherIDandActiveTab) { | 1835 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MatchingLauncherIDandActiveTab) { |
| 1834 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1836 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 1835 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 1837 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 1836 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 1838 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 1837 EXPECT_EQ(2, model_->item_count()); | 1839 EXPECT_EQ(2, model_->item_count()); |
| 1838 | 1840 |
| 1839 aura::Window* window = browser()->window()->GetNativeWindow(); | 1841 aura::Window* window = browser()->window()->GetNativeWindow(); |
| 1840 | 1842 |
| 1841 int browser_index = ash::GetBrowserItemIndex(*model_); | 1843 int browser_index = |
| 1844 ash::GetLauncherItemIndexForType(ash::TYPE_BROWSER_SHORTCUT, *model_); |
| 1842 ash::LauncherID browser_id = model_->items()[browser_index].id; | 1845 ash::LauncherID browser_id = model_->items()[browser_index].id; |
| 1843 EXPECT_EQ(browser_id, controller_->GetIDByWindow(window)); | 1846 EXPECT_EQ(browser_id, controller_->GetIDByWindow(window)); |
| 1844 | 1847 |
| 1845 ash::LauncherID app_id = CreateShortcut("app1"); | 1848 ash::LauncherID app_id = CreateShortcut("app1"); |
| 1846 EXPECT_EQ(3, model_->item_count()); | 1849 EXPECT_EQ(3, model_->item_count()); |
| 1847 | 1850 |
| 1848 // Creates a new tab for "app1" and checks that GetIDByWindow() returns | 1851 // Creates a new tab for "app1" and checks that GetIDByWindow() returns |
| 1849 // |LauncherID| of "app1". | 1852 // |LauncherID| of "app1". |
| 1850 ActivateLauncherItem(model_->ItemIndexByID(app_id)); | 1853 ActivateLauncherItem(model_->ItemIndexByID(app_id)); |
| 1851 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 1854 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1881 // Now show overflow bubble. | 1884 // Now show overflow bubble. |
| 1882 test.ShowOverflowBubble(); | 1885 test.ShowOverflowBubble(); |
| 1883 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); | 1886 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); |
| 1884 | 1887 |
| 1885 // Unpin first pinned app and there should be no crash. | 1888 // Unpin first pinned app and there should be no crash. |
| 1886 controller_->UnpinAppWithID(std::string("fake_app_0")); | 1889 controller_->UnpinAppWithID(std::string("fake_app_0")); |
| 1887 | 1890 |
| 1888 test.RunMessageLoopUntilAnimationsDone(); | 1891 test.RunMessageLoopUntilAnimationsDone(); |
| 1889 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); | 1892 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); |
| 1890 } | 1893 } |
| OLD | NEW |