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