| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 destroyed_watcher.Wait(); | 867 destroyed_watcher.Wait(); |
| 868 EXPECT_EQ(--tab_count, tab_strip->count()); | 868 EXPECT_EQ(--tab_count, tab_strip->count()); |
| 869 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 869 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
| 870 } | 870 } |
| 871 | 871 |
| 872 // Launch the app first and then create the shortcut. | 872 // Launch the app first and then create the shortcut. |
| 873 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchUnpinned) { | 873 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchUnpinned) { |
| 874 TabStripModel* tab_strip = browser()->tab_strip_model(); | 874 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 875 int tab_count = tab_strip->count(); | 875 int tab_count = tab_strip->count(); |
| 876 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, | 876 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
| 877 NEW_FOREGROUND_TAB); | 877 WindowOpenDisposition::NEW_FOREGROUND_TAB); |
| 878 EXPECT_EQ(++tab_count, tab_strip->count()); | 878 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 879 ash::ShelfID shortcut_id = CreateShortcut("app1"); | 879 ash::ShelfID shortcut_id = CreateShortcut("app1"); |
| 880 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 880 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
| 881 WebContents* tab = tab_strip->GetActiveWebContents(); | 881 WebContents* tab = tab_strip->GetActiveWebContents(); |
| 882 content::WebContentsDestroyedWatcher destroyed_watcher(tab); | 882 content::WebContentsDestroyedWatcher destroyed_watcher(tab); |
| 883 browser()->tab_strip_model()->CloseSelectedTabs(); | 883 browser()->tab_strip_model()->CloseSelectedTabs(); |
| 884 destroyed_watcher.Wait(); | 884 destroyed_watcher.Wait(); |
| 885 EXPECT_EQ(--tab_count, tab_strip->count()); | 885 EXPECT_EQ(--tab_count, tab_strip->count()); |
| 886 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 886 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
| 887 } | 887 } |
| 888 | 888 |
| 889 // Launches an app in the background and then tries to open it. This is test for | 889 // Launches an app in the background and then tries to open it. This is test for |
| 890 // a crash we had. | 890 // a crash we had. |
| 891 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchInBackground) { | 891 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchInBackground) { |
| 892 TabStripModel* tab_strip = browser()->tab_strip_model(); | 892 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 893 int tab_count = tab_strip->count(); | 893 int tab_count = tab_strip->count(); |
| 894 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, | 894 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
| 895 NEW_BACKGROUND_TAB); | 895 WindowOpenDisposition::NEW_BACKGROUND_TAB); |
| 896 EXPECT_EQ(++tab_count, tab_strip->count()); | 896 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 897 controller_->LaunchApp(last_loaded_extension_id(), | 897 controller_->LaunchApp(last_loaded_extension_id(), |
| 898 ash::LAUNCH_FROM_UNKNOWN, | 898 ash::LAUNCH_FROM_UNKNOWN, |
| 899 0); | 899 0); |
| 900 } | 900 } |
| 901 | 901 |
| 902 // Confirm that clicking a icon for an app running in one of 2 maxmized windows | 902 // Confirm that clicking a icon for an app running in one of 2 maxmized windows |
| 903 // activates the right window. | 903 // activates the right window. |
| 904 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchMaximized) { | 904 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchMaximized) { |
| 905 aura::Window* window1 = browser()->window()->GetNativeWindow(); | 905 aura::Window* window1 = browser()->window()->GetNativeWindow(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 929 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 929 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
| 930 } | 930 } |
| 931 | 931 |
| 932 // Activating the same app multiple times should launch only a single copy. | 932 // Activating the same app multiple times should launch only a single copy. |
| 933 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ActivateApp) { | 933 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ActivateApp) { |
| 934 TabStripModel* tab_strip = browser()->tab_strip_model(); | 934 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 935 int tab_count = tab_strip->count(); | 935 int tab_count = tab_strip->count(); |
| 936 const Extension* extension = | 936 const Extension* extension = |
| 937 LoadExtension(test_data_dir_.AppendASCII("app1")); | 937 LoadExtension(test_data_dir_.AppendASCII("app1")); |
| 938 | 938 |
| 939 controller_->ActivateApp(extension->id(), | 939 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); |
| 940 ash::LAUNCH_FROM_UNKNOWN, | |
| 941 0); | |
| 942 EXPECT_EQ(++tab_count, tab_strip->count()); | 940 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 943 controller_->ActivateApp(extension->id(), | 941 controller_->ActivateApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); |
| 944 ash::LAUNCH_FROM_UNKNOWN, | |
| 945 0); | |
| 946 EXPECT_EQ(tab_count, tab_strip->count()); | 942 EXPECT_EQ(tab_count, tab_strip->count()); |
| 947 } | 943 } |
| 948 | 944 |
| 949 // Launching the same app multiple times should launch a copy for each call. | 945 // Launching the same app multiple times should launch a copy for each call. |
| 950 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchApp) { | 946 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchApp) { |
| 951 TabStripModel* tab_strip = browser()->tab_strip_model(); | 947 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 952 int tab_count = tab_strip->count(); | 948 int tab_count = tab_strip->count(); |
| 953 const Extension* extension = | 949 const Extension* extension = |
| 954 LoadExtension(test_data_dir_.AppendASCII("app1")); | 950 LoadExtension(test_data_dir_.AppendASCII("app1")); |
| 955 | 951 |
| 956 controller_->LaunchApp(extension->id(), | 952 controller_->LaunchApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); |
| 957 ash::LAUNCH_FROM_UNKNOWN, | |
| 958 0); | |
| 959 EXPECT_EQ(++tab_count, tab_strip->count()); | 953 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 960 controller_->LaunchApp(extension->id(), | 954 controller_->LaunchApp(extension->id(), ash::LAUNCH_FROM_UNKNOWN, 0); |
| 961 ash::LAUNCH_FROM_UNKNOWN, | |
| 962 0); | |
| 963 EXPECT_EQ(++tab_count, tab_strip->count()); | 955 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 964 } | 956 } |
| 965 | 957 |
| 966 // Launch 2 apps and toggle which is active. | 958 // Launch 2 apps and toggle which is active. |
| 967 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultipleApps) { | 959 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultipleApps) { |
| 968 int item_count = model_->item_count(); | 960 int item_count = model_->item_count(); |
| 969 TabStripModel* tab_strip = browser()->tab_strip_model(); | 961 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 970 int tab_count = tab_strip->count(); | 962 int tab_count = tab_strip->count(); |
| 971 ash::ShelfID shortcut1 = CreateShortcut("app1"); | 963 ash::ShelfID shortcut1 = CreateShortcut("app1"); |
| 972 EXPECT_EQ(++item_count, model_->item_count()); | 964 EXPECT_EQ(++item_count, model_->item_count()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 989 | 981 |
| 990 // Reactivate first app. | 982 // Reactivate first app. |
| 991 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut1)); | 983 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut1)); |
| 992 EXPECT_EQ(tab_count, tab_strip->count()); | 984 EXPECT_EQ(tab_count, tab_strip->count()); |
| 993 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1); | 985 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1); |
| 994 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); | 986 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); |
| 995 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); | 987 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); |
| 996 | 988 |
| 997 // Open second tab for second app. This should activate it. | 989 // Open second tab for second app. This should activate it. |
| 998 ui_test_utils::NavigateToURLWithDisposition( | 990 ui_test_utils::NavigateToURLWithDisposition( |
| 999 browser(), | 991 browser(), GURL("http://www.example.com/path3/foo.html"), |
| 1000 GURL("http://www.example.com/path3/foo.html"), | 992 WindowOpenDisposition::NEW_FOREGROUND_TAB, 0); |
| 1001 NEW_FOREGROUND_TAB, | |
| 1002 0); | |
| 1003 EXPECT_EQ(++tab_count, tab_strip->count()); | 993 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1004 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); | 994 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); |
| 1005 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); | 995 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); |
| 1006 | 996 |
| 1007 // Reactivate first app. | 997 // Reactivate first app. |
| 1008 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut1)); | 998 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut1)); |
| 1009 EXPECT_EQ(tab_count, tab_strip->count()); | 999 EXPECT_EQ(tab_count, tab_strip->count()); |
| 1010 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1); | 1000 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1); |
| 1011 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); | 1001 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); |
| 1012 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); | 1002 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1075 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1086 int tab_count = tab_strip->count(); | 1076 int tab_count = tab_strip->count(); |
| 1087 ash::ShelfID shortcut_id = CreateShortcut("app1"); | 1077 ash::ShelfID shortcut_id = CreateShortcut("app1"); |
| 1088 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); | 1078 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
| 1089 EXPECT_EQ(++tab_count, tab_strip->count()); | 1079 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1090 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1080 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 1091 WebContents* first_tab = tab_strip->GetActiveWebContents(); | 1081 WebContents* first_tab = tab_strip->GetActiveWebContents(); |
| 1092 | 1082 |
| 1093 // Create new tab owned by app. | 1083 // Create new tab owned by app. |
| 1094 ui_test_utils::NavigateToURLWithDisposition( | 1084 ui_test_utils::NavigateToURLWithDisposition( |
| 1095 browser(), | 1085 browser(), GURL("http://www.example.com/path2/bar.html"), |
| 1096 GURL("http://www.example.com/path2/bar.html"), | 1086 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 1097 NEW_FOREGROUND_TAB, | |
| 1098 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1087 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1099 EXPECT_EQ(++tab_count, tab_strip->count()); | 1088 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1100 // Confirm app is still active. | 1089 // Confirm app is still active. |
| 1101 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1090 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 1102 | 1091 |
| 1103 // Create new tab not owned by app. | 1092 // Create new tab not owned by app. |
| 1104 ui_test_utils::NavigateToURLWithDisposition( | 1093 ui_test_utils::NavigateToURLWithDisposition( |
| 1105 browser(), | 1094 browser(), GURL("http://www.example.com/path3/foo.html"), |
| 1106 GURL("http://www.example.com/path3/foo.html"), | 1095 WindowOpenDisposition::NEW_FOREGROUND_TAB, 0); |
| 1107 NEW_FOREGROUND_TAB, | |
| 1108 0); | |
| 1109 EXPECT_EQ(++tab_count, tab_strip->count()); | 1096 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1110 // No longer active. | 1097 // No longer active. |
| 1111 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); | 1098 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); |
| 1112 | 1099 |
| 1113 // Activating app makes first tab active again. | 1100 // Activating app makes first tab active again. |
| 1114 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); | 1101 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
| 1115 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1102 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 1116 EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab); | 1103 EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab); |
| 1117 } | 1104 } |
| 1118 | 1105 |
| 1119 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, RefocusFilter) { | 1106 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, RefocusFilter) { |
| 1120 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1107 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1121 int tab_count = tab_strip->count(); | 1108 int tab_count = tab_strip->count(); |
| 1122 ash::ShelfID shortcut_id = CreateShortcut("app1"); | 1109 ash::ShelfID shortcut_id = CreateShortcut("app1"); |
| 1123 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); | 1110 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
| 1124 EXPECT_EQ(++tab_count, tab_strip->count()); | 1111 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1125 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1112 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 1126 WebContents* first_tab = tab_strip->GetActiveWebContents(); | 1113 WebContents* first_tab = tab_strip->GetActiveWebContents(); |
| 1127 | 1114 |
| 1128 controller_->SetRefocusURLPatternForTest( | 1115 controller_->SetRefocusURLPatternForTest( |
| 1129 shortcut_id, GURL("http://www.example.com/path1/*")); | 1116 shortcut_id, GURL("http://www.example.com/path1/*")); |
| 1130 // Create new tab owned by app. | 1117 // Create new tab owned by app. |
| 1131 ui_test_utils::NavigateToURLWithDisposition( | 1118 ui_test_utils::NavigateToURLWithDisposition( |
| 1132 browser(), | 1119 browser(), GURL("http://www.example.com/path2/bar.html"), |
| 1133 GURL("http://www.example.com/path2/bar.html"), | 1120 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 1134 NEW_FOREGROUND_TAB, | |
| 1135 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1121 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1136 EXPECT_EQ(++tab_count, tab_strip->count()); | 1122 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1137 // Confirm app is still active. | 1123 // Confirm app is still active. |
| 1138 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1124 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 1139 | 1125 |
| 1140 // Create new tab not owned by app. | 1126 // Create new tab not owned by app. |
| 1141 ui_test_utils::NavigateToURLWithDisposition( | 1127 ui_test_utils::NavigateToURLWithDisposition( |
| 1142 browser(), | 1128 browser(), GURL("http://www.example.com/path3/foo.html"), |
| 1143 GURL("http://www.example.com/path3/foo.html"), | 1129 WindowOpenDisposition::NEW_FOREGROUND_TAB, 0); |
| 1144 NEW_FOREGROUND_TAB, | |
| 1145 0); | |
| 1146 EXPECT_EQ(++tab_count, tab_strip->count()); | 1130 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1147 // No longer active. | 1131 // No longer active. |
| 1148 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); | 1132 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); |
| 1149 | 1133 |
| 1150 // Activating app makes first tab active again, because second tab isn't | 1134 // Activating app makes first tab active again, because second tab isn't |
| 1151 // in its refocus url path. | 1135 // in its refocus url path. |
| 1152 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); | 1136 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
| 1153 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1137 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 1154 EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab); | 1138 EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab); |
| 1155 } | 1139 } |
| 1156 | 1140 |
| 1157 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, RefocusFilterLaunch) { | 1141 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, RefocusFilterLaunch) { |
| 1158 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1142 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1159 int tab_count = tab_strip->count(); | 1143 int tab_count = tab_strip->count(); |
| 1160 ash::ShelfID shortcut_id = CreateShortcut("app1"); | 1144 ash::ShelfID shortcut_id = CreateShortcut("app1"); |
| 1161 controller_->SetRefocusURLPatternForTest( | 1145 controller_->SetRefocusURLPatternForTest( |
| 1162 shortcut_id, GURL("http://www.example.com/path1/*")); | 1146 shortcut_id, GURL("http://www.example.com/path1/*")); |
| 1163 | 1147 |
| 1164 // Create new tab. | 1148 // Create new tab. |
| 1165 ui_test_utils::NavigateToURLWithDisposition( | 1149 ui_test_utils::NavigateToURLWithDisposition( |
| 1166 browser(), | 1150 browser(), GURL("http://www.example2.com/path2/bar.html"), |
| 1167 GURL("http://www.example2.com/path2/bar.html"), | 1151 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 1168 NEW_FOREGROUND_TAB, | |
| 1169 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1152 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1170 EXPECT_EQ(++tab_count, tab_strip->count()); | 1153 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 1171 WebContents* first_tab = tab_strip->GetActiveWebContents(); | 1154 WebContents* first_tab = tab_strip->GetActiveWebContents(); |
| 1172 // Confirm app is not active. | 1155 // Confirm app is not active. |
| 1173 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1156 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
| 1174 | 1157 |
| 1175 // Activating app should launch new tab, because second tab isn't | 1158 // Activating app should launch new tab, because second tab isn't |
| 1176 // in its refocus url path. | 1159 // in its refocus url path. |
| 1177 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); | 1160 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
| 1178 EXPECT_EQ(++tab_count, tab_strip->count()); | 1161 EXPECT_EQ(++tab_count, tab_strip->count()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1194 | 1177 |
| 1195 ash::ShelfID shortcut_id = CreateShortcut("app1"); | 1178 ash::ShelfID shortcut_id = CreateShortcut("app1"); |
| 1196 controller_->SetRefocusURLPatternForTest( | 1179 controller_->SetRefocusURLPatternForTest( |
| 1197 shortcut_id, GURL("http://www.example.com/path1/*")); | 1180 shortcut_id, GURL("http://www.example.com/path1/*")); |
| 1198 | 1181 |
| 1199 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1182 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
| 1200 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); | 1183 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); |
| 1201 | 1184 |
| 1202 // Create new tab which would be the running app. | 1185 // Create new tab which would be the running app. |
| 1203 ui_test_utils::NavigateToURLWithDisposition( | 1186 ui_test_utils::NavigateToURLWithDisposition( |
| 1204 browser(), | 1187 browser(), GURL("http://www.example.com/path1/bar.html"), |
| 1205 GURL("http://www.example.com/path1/bar.html"), | 1188 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 1206 NEW_FOREGROUND_TAB, | |
| 1207 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1189 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1208 | 1190 |
| 1209 // There should never be two items active at the same time. | 1191 // There should never be two items active at the same time. |
| 1210 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1192 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 1211 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status); | 1193 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status); |
| 1212 | 1194 |
| 1213 tab_strip->ActivateTabAt(0, false); | 1195 tab_strip->ActivateTabAt(0, false); |
| 1214 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); | 1196 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); |
| 1215 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); | 1197 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status); |
| 1216 | 1198 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1230 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1212 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1231 | 1213 |
| 1232 ash::ShelfID shortcut_id = CreateShortcut("app1"); | 1214 ash::ShelfID shortcut_id = CreateShortcut("app1"); |
| 1233 controller_->SetRefocusURLPatternForTest( | 1215 controller_->SetRefocusURLPatternForTest( |
| 1234 shortcut_id, GURL("http://www.example.com/path1/*")); | 1216 shortcut_id, GURL("http://www.example.com/path1/*")); |
| 1235 | 1217 |
| 1236 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1218 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
| 1237 | 1219 |
| 1238 // Create new tab which would be the running app. | 1220 // Create new tab which would be the running app. |
| 1239 ui_test_utils::NavigateToURLWithDisposition( | 1221 ui_test_utils::NavigateToURLWithDisposition( |
| 1240 browser(), | 1222 browser(), GURL("http://www.example.com/path1/bar.html"), |
| 1241 GURL("http://www.example.com/path1/bar.html"), | 1223 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 1242 NEW_FOREGROUND_TAB, | |
| 1243 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1224 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1244 | 1225 |
| 1245 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 1226 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 1246 // To address the issue of crbug.com/174050, the tab we are about to close | 1227 // To address the issue of crbug.com/174050, the tab we are about to close |
| 1247 // has to be active. | 1228 // has to be active. |
| 1248 tab_strip->ActivateTabAt(1, false); | 1229 tab_strip->ActivateTabAt(1, false); |
| 1249 EXPECT_EQ(1, tab_strip->active_index()); | 1230 EXPECT_EQ(1, tab_strip->active_index()); |
| 1250 | 1231 |
| 1251 // Close the web contents. | 1232 // Close the web contents. |
| 1252 tab_strip->CloseWebContentsAt(1, TabStripModel::CLOSE_NONE); | 1233 tab_strip->CloseWebContentsAt(1, TabStripModel::CLOSE_NONE); |
| 1253 // The status should now be set to closed. | 1234 // The status should now be set to closed. |
| 1254 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1235 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
| 1255 } | 1236 } |
| 1256 | 1237 |
| 1257 // Test that the App window could restore to its previous window state from | 1238 // Test that the App window could restore to its previous window state from |
| 1258 // before it was closed. | 1239 // before it was closed. |
| 1259 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, AppWindowRestoreBehaviorTest) { | 1240 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, AppWindowRestoreBehaviorTest) { |
| 1260 // Open an App, maximized its window, and close it. | 1241 // Open an App, maximized its window, and close it. |
| 1261 const Extension* extension = LoadAndLaunchExtension( | 1242 const Extension* extension = |
| 1262 "app1", extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW); | 1243 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_WINDOW, |
| 1244 WindowOpenDisposition::NEW_WINDOW); |
| 1263 Browser* app_browser = FindBrowserForApp(extension->id()); | 1245 Browser* app_browser = FindBrowserForApp(extension->id()); |
| 1264 ASSERT_TRUE(app_browser); | 1246 ASSERT_TRUE(app_browser); |
| 1265 aura::Window* window = app_browser->window()->GetNativeWindow(); | 1247 aura::Window* window = app_browser->window()->GetNativeWindow(); |
| 1266 EXPECT_FALSE(ash::wm::GetWindowState(window)->IsMaximized()); | 1248 EXPECT_FALSE(ash::wm::GetWindowState(window)->IsMaximized()); |
| 1267 ash::wm::GetWindowState(window)->Maximize(); | 1249 ash::wm::GetWindowState(window)->Maximize(); |
| 1268 EXPECT_TRUE(ash::wm::GetWindowState(window)->IsMaximized()); | 1250 EXPECT_TRUE(ash::wm::GetWindowState(window)->IsMaximized()); |
| 1269 CloseAppBrowserWindow(app_browser); | 1251 CloseAppBrowserWindow(app_browser); |
| 1270 | 1252 |
| 1271 // Reopen the App. It should start maximized. Un-maximize it and close it. | 1253 // Reopen the App. It should start maximized. Un-maximize it and close it. |
| 1272 extension = LoadAndLaunchExtension( | 1254 extension = |
| 1273 "app1", extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW); | 1255 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_WINDOW, |
| 1256 WindowOpenDisposition::NEW_WINDOW); |
| 1274 app_browser = FindBrowserForApp(extension->id()); | 1257 app_browser = FindBrowserForApp(extension->id()); |
| 1275 ASSERT_TRUE(app_browser); | 1258 ASSERT_TRUE(app_browser); |
| 1276 window = app_browser->window()->GetNativeWindow(); | 1259 window = app_browser->window()->GetNativeWindow(); |
| 1277 EXPECT_TRUE(ash::wm::GetWindowState(window)->IsMaximized()); | 1260 EXPECT_TRUE(ash::wm::GetWindowState(window)->IsMaximized()); |
| 1278 | 1261 |
| 1279 ash::wm::GetWindowState(window)->Restore(); | 1262 ash::wm::GetWindowState(window)->Restore(); |
| 1280 EXPECT_FALSE(ash::wm::GetWindowState(window)->IsMaximized()); | 1263 EXPECT_FALSE(ash::wm::GetWindowState(window)->IsMaximized()); |
| 1281 app_browser->window()->Close(); | 1264 app_browser->window()->Close(); |
| 1282 CloseAppBrowserWindow(app_browser); | 1265 CloseAppBrowserWindow(app_browser); |
| 1283 | 1266 |
| 1284 // Reopen the App. It should start un-maximized. | 1267 // Reopen the App. It should start un-maximized. |
| 1285 extension = LoadAndLaunchExtension( | 1268 extension = |
| 1286 "app1", extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW); | 1269 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_WINDOW, |
| 1270 WindowOpenDisposition::NEW_WINDOW); |
| 1287 app_browser = FindBrowserForApp(extension->id()); | 1271 app_browser = FindBrowserForApp(extension->id()); |
| 1288 ASSERT_TRUE(app_browser); | 1272 ASSERT_TRUE(app_browser); |
| 1289 window = app_browser->window()->GetNativeWindow(); | 1273 window = app_browser->window()->GetNativeWindow(); |
| 1290 EXPECT_FALSE(ash::wm::GetWindowState(window)->IsMaximized()); | 1274 EXPECT_FALSE(ash::wm::GetWindowState(window)->IsMaximized()); |
| 1291 } | 1275 } |
| 1292 | 1276 |
| 1293 // Checks that a windowed application does not add an item to the browser list. | 1277 // Checks that a windowed application does not add an item to the browser list. |
| 1294 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, | 1278 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
| 1295 WindowedAppDoesNotAddToBrowser) { | 1279 WindowedAppDoesNotAddToBrowser) { |
| 1296 // Get the number of items in the browser menu. | 1280 // Get the number of items in the browser menu. |
| 1297 size_t items = NumberOfDetectedLauncherBrowsers(false); | 1281 size_t items = NumberOfDetectedLauncherBrowsers(false); |
| 1298 size_t running_browser = chrome::GetTotalBrowserCount(); | 1282 size_t running_browser = chrome::GetTotalBrowserCount(); |
| 1299 EXPECT_EQ(0u, items); | 1283 EXPECT_EQ(0u, items); |
| 1300 EXPECT_EQ(0u, running_browser); | 1284 EXPECT_EQ(0u, running_browser); |
| 1301 | 1285 |
| 1302 LoadAndLaunchExtension( | 1286 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_WINDOW, |
| 1303 "app1", extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW); | 1287 WindowOpenDisposition::NEW_WINDOW); |
| 1304 | 1288 |
| 1305 // No new browser should get detected, even though one more is running. | 1289 // No new browser should get detected, even though one more is running. |
| 1306 EXPECT_EQ(0u, NumberOfDetectedLauncherBrowsers(false)); | 1290 EXPECT_EQ(0u, NumberOfDetectedLauncherBrowsers(false)); |
| 1307 EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount()); | 1291 EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount()); |
| 1308 | 1292 |
| 1309 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); | 1293 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
| 1294 WindowOpenDisposition::NEW_WINDOW); |
| 1310 | 1295 |
| 1311 // A new browser should get detected and one more should be running. | 1296 // A new browser should get detected and one more should be running. |
| 1312 EXPECT_EQ(NumberOfDetectedLauncherBrowsers(false), 1u); | 1297 EXPECT_EQ(NumberOfDetectedLauncherBrowsers(false), 1u); |
| 1313 EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount()); | 1298 EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount()); |
| 1314 } | 1299 } |
| 1315 | 1300 |
| 1316 // Checks the functionality to enumerate all browsers vs. all tabs. | 1301 // Checks the functionality to enumerate all browsers vs. all tabs. |
| 1317 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, | 1302 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
| 1318 EnumerateALlBrowsersAndTabs) { | 1303 EnumerateAllBrowsersAndTabs) { |
| 1319 // Create at least one browser. | 1304 // Create at least one browser. |
| 1320 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); | 1305 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
| 1306 WindowOpenDisposition::NEW_WINDOW); |
| 1321 size_t browsers = NumberOfDetectedLauncherBrowsers(false); | 1307 size_t browsers = NumberOfDetectedLauncherBrowsers(false); |
| 1322 size_t tabs = NumberOfDetectedLauncherBrowsers(true); | 1308 size_t tabs = NumberOfDetectedLauncherBrowsers(true); |
| 1323 | 1309 |
| 1324 // Create a second browser. | 1310 // Create a second browser. |
| 1325 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); | 1311 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
| 1312 WindowOpenDisposition::NEW_WINDOW); |
| 1326 | 1313 |
| 1327 EXPECT_EQ(++browsers, NumberOfDetectedLauncherBrowsers(false)); | 1314 EXPECT_EQ(++browsers, NumberOfDetectedLauncherBrowsers(false)); |
| 1328 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); | 1315 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); |
| 1329 | 1316 |
| 1330 // Create only a tab. | 1317 // Create only a tab. |
| 1331 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, | 1318 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
| 1332 NEW_FOREGROUND_TAB); | 1319 WindowOpenDisposition::NEW_FOREGROUND_TAB); |
| 1333 | 1320 |
| 1334 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false)); | 1321 EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false)); |
| 1335 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); | 1322 EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true)); |
| 1336 } | 1323 } |
| 1337 | 1324 |
| 1338 // Check that the keyboard activation of a launcher item tabs properly through | 1325 // Check that the keyboard activation of a launcher item tabs properly through |
| 1339 // the items at hand. | 1326 // the items at hand. |
| 1340 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, AltNumberTabsTabbing) { | 1327 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, AltNumberTabsTabbing) { |
| 1341 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1328 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1342 | 1329 |
| 1343 ash::ShelfID shortcut_id = CreateShortcut("app"); | 1330 ash::ShelfID shortcut_id = CreateShortcut("app"); |
| 1344 controller_->SetRefocusURLPatternForTest( | 1331 controller_->SetRefocusURLPatternForTest( |
| 1345 shortcut_id, GURL("http://www.example.com/path/*")); | 1332 shortcut_id, GURL("http://www.example.com/path/*")); |
| 1346 std::string url = "http://www.example.com/path/bla"; | 1333 std::string url = "http://www.example.com/path/bla"; |
| 1347 | 1334 |
| 1348 int shortcut_index = model_->ItemIndexByID(shortcut_id); | 1335 int shortcut_index = model_->ItemIndexByID(shortcut_id); |
| 1349 | 1336 |
| 1350 // Create an application handled browser tab. | 1337 // Create an application handled browser tab. |
| 1351 ui_test_utils::NavigateToURLWithDisposition( | 1338 ui_test_utils::NavigateToURLWithDisposition( |
| 1352 browser(), | 1339 browser(), GURL(url), WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 1353 GURL(url), | |
| 1354 NEW_FOREGROUND_TAB, | |
| 1355 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1340 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1356 | 1341 |
| 1357 content::WebContents* content1 = tab_strip->GetActiveWebContents(); | 1342 content::WebContents* content1 = tab_strip->GetActiveWebContents(); |
| 1358 | 1343 |
| 1359 // Create some other browser tab. | 1344 // Create some other browser tab. |
| 1360 ui_test_utils::NavigateToURLWithDisposition( | 1345 ui_test_utils::NavigateToURLWithDisposition( |
| 1361 browser(), | 1346 browser(), GURL("http://www.test.com"), |
| 1362 GURL("http://www.test.com"), | 1347 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 1363 NEW_FOREGROUND_TAB, | |
| 1364 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1348 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1365 content::WebContents* content1a = tab_strip->GetActiveWebContents(); | 1349 content::WebContents* content1a = tab_strip->GetActiveWebContents(); |
| 1366 | 1350 |
| 1367 // Make sure that the active tab is now our handled tab. | 1351 // Make sure that the active tab is now our handled tab. |
| 1368 EXPECT_NE(content1a, content1); | 1352 EXPECT_NE(content1a, content1); |
| 1369 | 1353 |
| 1370 // The active tab should still be the unnamed tab. Then we switch and reach | 1354 // The active tab should still be the unnamed tab. Then we switch and reach |
| 1371 // the first app and stay there. | 1355 // the first app and stay there. |
| 1372 EXPECT_EQ(content1a, tab_strip->GetActiveWebContents()); | 1356 EXPECT_EQ(content1a, tab_strip->GetActiveWebContents()); |
| 1373 WmShelf::ActivateShelfItem(shortcut_index); | 1357 WmShelf::ActivateShelfItem(shortcut_index); |
| 1374 EXPECT_EQ(content1, tab_strip->GetActiveWebContents()); | 1358 EXPECT_EQ(content1, tab_strip->GetActiveWebContents()); |
| 1375 WmShelf::ActivateShelfItem(shortcut_index); | 1359 WmShelf::ActivateShelfItem(shortcut_index); |
| 1376 EXPECT_EQ(content1, tab_strip->GetActiveWebContents()); | 1360 EXPECT_EQ(content1, tab_strip->GetActiveWebContents()); |
| 1377 | 1361 |
| 1378 ui_test_utils::NavigateToURLWithDisposition( | 1362 ui_test_utils::NavigateToURLWithDisposition( |
| 1379 browser(), | 1363 browser(), GURL(url), WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 1380 GURL(url), | |
| 1381 NEW_FOREGROUND_TAB, | |
| 1382 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1364 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1383 content::WebContents* content2 = tab_strip->GetActiveWebContents(); | 1365 content::WebContents* content2 = tab_strip->GetActiveWebContents(); |
| 1384 | 1366 |
| 1385 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); | 1367 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); |
| 1386 WmShelf::ActivateShelfItem(shortcut_index); | 1368 WmShelf::ActivateShelfItem(shortcut_index); |
| 1387 EXPECT_EQ(content1, browser()->tab_strip_model()->GetActiveWebContents()); | 1369 EXPECT_EQ(content1, browser()->tab_strip_model()->GetActiveWebContents()); |
| 1388 WmShelf::ActivateShelfItem(shortcut_index); | 1370 WmShelf::ActivateShelfItem(shortcut_index); |
| 1389 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); | 1371 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); |
| 1390 } | 1372 } |
| 1391 | 1373 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 WmShelf::ActivateShelfItem(1); | 1652 WmShelf::ActivateShelfItem(1); |
| 1671 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); | 1653 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); |
| 1672 WmShelf::ActivateShelfItem(1); | 1654 WmShelf::ActivateShelfItem(1); |
| 1673 EXPECT_EQ(window2, ash::wm::GetActiveWindow()); | 1655 EXPECT_EQ(window2, ash::wm::GetActiveWindow()); |
| 1674 WmShelf::ActivateShelfItem(1); | 1656 WmShelf::ActivateShelfItem(1); |
| 1675 EXPECT_EQ(window3, ash::wm::GetActiveWindow()); | 1657 EXPECT_EQ(window3, ash::wm::GetActiveWindow()); |
| 1676 WmShelf::ActivateShelfItem(1); | 1658 WmShelf::ActivateShelfItem(1); |
| 1677 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); | 1659 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); |
| 1678 | 1660 |
| 1679 // Create anther app and make sure that none of our browsers is active. | 1661 // Create anther app and make sure that none of our browsers is active. |
| 1680 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, NEW_WINDOW); | 1662 LoadAndLaunchExtension("app1", extensions::LAUNCH_CONTAINER_TAB, |
| 1663 WindowOpenDisposition::NEW_WINDOW); |
| 1681 EXPECT_NE(window1, ash::wm::GetActiveWindow()); | 1664 EXPECT_NE(window1, ash::wm::GetActiveWindow()); |
| 1682 EXPECT_NE(window2, ash::wm::GetActiveWindow()); | 1665 EXPECT_NE(window2, ash::wm::GetActiveWindow()); |
| 1683 | 1666 |
| 1684 // After activation our browser should be active again. | 1667 // After activation our browser should be active again. |
| 1685 WmShelf::ActivateShelfItem(1); | 1668 WmShelf::ActivateShelfItem(1); |
| 1686 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); | 1669 EXPECT_EQ(window1, ash::wm::GetActiveWindow()); |
| 1687 } | 1670 } |
| 1688 | 1671 |
| 1689 // Checks that after a session restore, we do not start applications on an | 1672 // Checks that after a session restore, we do not start applications on an |
| 1690 // activation. | 1673 // activation. |
| 1691 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ActivateAfterSessionRestore) { | 1674 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ActivateAfterSessionRestore) { |
| 1692 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1675 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 1693 | 1676 |
| 1694 // Create a known application. | 1677 // Create a known application. |
| 1695 ash::ShelfID shortcut_id = CreateShortcut("app1"); | 1678 ash::ShelfID shortcut_id = CreateShortcut("app1"); |
| 1696 | 1679 |
| 1697 // Create a new browser - without activating it - and load an "app" into it. | 1680 // Create a new browser - without activating it - and load an "app" into it. |
| 1698 Browser::CreateParams params = Browser::CreateParams(profile()); | 1681 Browser::CreateParams params = Browser::CreateParams(profile()); |
| 1699 params.initial_show_state = ui::SHOW_STATE_INACTIVE; | 1682 params.initial_show_state = ui::SHOW_STATE_INACTIVE; |
| 1700 Browser* browser2 = new Browser(params); | 1683 Browser* browser2 = new Browser(params); |
| 1701 controller_->SetRefocusURLPatternForTest( | 1684 controller_->SetRefocusURLPatternForTest( |
| 1702 shortcut_id, GURL("http://www.example.com/path/*")); | 1685 shortcut_id, GURL("http://www.example.com/path/*")); |
| 1703 std::string url = "http://www.example.com/path/bla"; | 1686 std::string url = "http://www.example.com/path/bla"; |
| 1704 ui_test_utils::NavigateToURLWithDisposition( | 1687 ui_test_utils::NavigateToURLWithDisposition( |
| 1705 browser2, | 1688 browser2, GURL(url), WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 1706 GURL(url), | |
| 1707 NEW_FOREGROUND_TAB, | |
| 1708 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1689 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1709 | 1690 |
| 1710 // Remember the number of tabs for each browser. | 1691 // Remember the number of tabs for each browser. |
| 1711 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1692 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1712 int tab_count1 = tab_strip->count(); | 1693 int tab_count1 = tab_strip->count(); |
| 1713 TabStripModel* tab_strip2 = browser2->tab_strip_model(); | 1694 TabStripModel* tab_strip2 = browser2->tab_strip_model(); |
| 1714 int tab_count2 = tab_strip2->count(); | 1695 int tab_count2 = tab_strip2->count(); |
| 1715 | 1696 |
| 1716 // Check that we have two browsers and the inactive browser remained inactive. | 1697 // Check that we have two browsers and the inactive browser remained inactive. |
| 1717 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 1698 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2216 // We assume that the web store is always there (which it apparently is). | 2197 // We assume that the web store is always there (which it apparently is). |
| 2217 controller_->PinAppWithID(extensions::kWebStoreAppId); | 2198 controller_->PinAppWithID(extensions::kWebStoreAppId); |
| 2218 ash::ShelfID id = controller_->GetShelfIDForAppID( | 2199 ash::ShelfID id = controller_->GetShelfIDForAppID( |
| 2219 extensions::kWebStoreAppId); | 2200 extensions::kWebStoreAppId); |
| 2220 ASSERT_NE(0, id); | 2201 ASSERT_NE(0, id); |
| 2221 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); | 2202 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); |
| 2222 | 2203 |
| 2223 // Create a windowed application. | 2204 // Create a windowed application. |
| 2224 AppLaunchParams params = CreateAppLaunchParamsUserContainer( | 2205 AppLaunchParams params = CreateAppLaunchParamsUserContainer( |
| 2225 profile(), GetExtensionForAppID(extensions::kWebStoreAppId, profile()), | 2206 profile(), GetExtensionForAppID(extensions::kWebStoreAppId, profile()), |
| 2226 NEW_FOREGROUND_TAB, extensions::SOURCE_TEST); | 2207 WindowOpenDisposition::NEW_FOREGROUND_TAB, extensions::SOURCE_TEST); |
| 2227 params.container = extensions::LAUNCH_CONTAINER_WINDOW; | 2208 params.container = extensions::LAUNCH_CONTAINER_WINDOW; |
| 2228 OpenApplication(params); | 2209 OpenApplication(params); |
| 2229 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); | 2210 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); |
| 2230 | 2211 |
| 2231 // Find the browser which holds our app. | 2212 // Find the browser which holds our app. |
| 2232 Browser* app_browser = NULL; | 2213 Browser* app_browser = NULL; |
| 2233 const BrowserList* browser_list = BrowserList::GetInstance(); | 2214 const BrowserList* browser_list = BrowserList::GetInstance(); |
| 2234 for (BrowserList::const_reverse_iterator it = | 2215 for (BrowserList::const_reverse_iterator it = |
| 2235 browser_list->begin_last_active(); | 2216 browser_list->begin_last_active(); |
| 2236 it != browser_list->end_last_active() && !app_browser; ++it) { | 2217 it != browser_list->end_last_active() && !app_browser; ++it) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2301 // The apps should be closed. | 2282 // The apps should be closed. |
| 2302 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status); | 2283 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status); |
| 2303 EXPECT_EQ(ash::STATUS_CLOSED, | 2284 EXPECT_EQ(ash::STATUS_CLOSED, |
| 2304 model_->ItemByID(bookmark_app_shelf_id)->status); | 2285 model_->ItemByID(bookmark_app_shelf_id)->status); |
| 2305 | 2286 |
| 2306 // Navigate to the app's launch URLs in two tabs. | 2287 // Navigate to the app's launch URLs in two tabs. |
| 2307 ui_test_utils::NavigateToURL( | 2288 ui_test_utils::NavigateToURL( |
| 2308 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(hosted_app)); | 2289 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(hosted_app)); |
| 2309 ui_test_utils::NavigateToURLWithDisposition( | 2290 ui_test_utils::NavigateToURLWithDisposition( |
| 2310 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(bookmark_app), | 2291 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(bookmark_app), |
| 2311 NEW_FOREGROUND_TAB, 0); | 2292 WindowOpenDisposition::NEW_FOREGROUND_TAB, 0); |
| 2312 | 2293 |
| 2313 // The apps should now be running, with the last opened app active. | 2294 // The apps should now be running, with the last opened app active. |
| 2314 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); | 2295 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); |
| 2315 EXPECT_EQ(ash::STATUS_ACTIVE, | 2296 EXPECT_EQ(ash::STATUS_ACTIVE, |
| 2316 model_->ItemByID(bookmark_app_shelf_id)->status); | 2297 model_->ItemByID(bookmark_app_shelf_id)->status); |
| 2317 | 2298 |
| 2318 // Now use the launcher controller to activate the apps. | 2299 // Now use the launcher controller to activate the apps. |
| 2319 controller_->ActivateApp(hosted_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2300 controller_->ActivateApp(hosted_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
| 2320 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2301 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
| 2321 | 2302 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2352 // The apps should be closed. | 2333 // The apps should be closed. |
| 2353 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status); | 2334 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status); |
| 2354 EXPECT_EQ(ash::STATUS_CLOSED, | 2335 EXPECT_EQ(ash::STATUS_CLOSED, |
| 2355 model_->ItemByID(bookmark_app_shelf_id)->status); | 2336 model_->ItemByID(bookmark_app_shelf_id)->status); |
| 2356 | 2337 |
| 2357 // Navigate to the app's launch URLs in two tabs. | 2338 // Navigate to the app's launch URLs in two tabs. |
| 2358 ui_test_utils::NavigateToURL( | 2339 ui_test_utils::NavigateToURL( |
| 2359 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(hosted_app)); | 2340 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(hosted_app)); |
| 2360 ui_test_utils::NavigateToURLWithDisposition( | 2341 ui_test_utils::NavigateToURLWithDisposition( |
| 2361 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(bookmark_app), | 2342 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(bookmark_app), |
| 2362 NEW_FOREGROUND_TAB, 0); | 2343 WindowOpenDisposition::NEW_FOREGROUND_TAB, 0); |
| 2363 | 2344 |
| 2364 // The apps should still be closed. | 2345 // The apps should still be closed. |
| 2365 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status); | 2346 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status); |
| 2366 EXPECT_EQ(ash::STATUS_CLOSED, | 2347 EXPECT_EQ(ash::STATUS_CLOSED, |
| 2367 model_->ItemByID(bookmark_app_shelf_id)->status); | 2348 model_->ItemByID(bookmark_app_shelf_id)->status); |
| 2368 | 2349 |
| 2369 // Now use the launcher controller to activate the apps. | 2350 // Now use the launcher controller to activate the apps. |
| 2370 controller_->ActivateApp(hosted_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2351 controller_->ActivateApp(hosted_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
| 2371 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2352 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
| 2372 | 2353 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2391 | 2372 |
| 2392 // Close all windows via the menu item. | 2373 // Close all windows via the menu item. |
| 2393 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2374 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
| 2394 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2375 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
| 2395 | 2376 |
| 2396 // Check if "Close" is removed from the context menu. | 2377 // Check if "Close" is removed from the context menu. |
| 2397 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2378 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
| 2398 ASSERT_FALSE( | 2379 ASSERT_FALSE( |
| 2399 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2380 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
| 2400 } | 2381 } |
| OLD | NEW |