OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 // instantiated by the current user. | 2173 // instantiated by the current user. |
2174 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2174 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
2175 V2AppHandlingTwoUsers) { | 2175 V2AppHandlingTwoUsers) { |
2176 InitLauncherController(); | 2176 InitLauncherController(); |
2177 // Create a profile for our second user (will be destroyed by the framework). | 2177 // Create a profile for our second user (will be destroyed by the framework). |
2178 TestingProfile* profile2 = CreateMultiUserProfile("user2"); | 2178 TestingProfile* profile2 = CreateMultiUserProfile("user2"); |
2179 // Check that there is a browser and a app launcher. | 2179 // Check that there is a browser and a app launcher. |
2180 EXPECT_EQ(2, model_->item_count()); | 2180 EXPECT_EQ(2, model_->item_count()); |
2181 | 2181 |
2182 // Add a v2 app. | 2182 // Add a v2 app. |
2183 V2App v2_app(profile(), extension1_); | 2183 V2App v2_app(profile(), extension1_.get()); |
2184 EXPECT_EQ(3, model_->item_count()); | 2184 EXPECT_EQ(3, model_->item_count()); |
2185 | 2185 |
2186 // After switching users the item should go away. | 2186 // After switching users the item should go away. |
2187 SwitchActiveUser(profile2->GetProfileName()); | 2187 SwitchActiveUser(profile2->GetProfileName()); |
2188 EXPECT_EQ(2, model_->item_count()); | 2188 EXPECT_EQ(2, model_->item_count()); |
2189 | 2189 |
2190 // And it should come back when switching back. | 2190 // And it should come back when switching back. |
2191 SwitchActiveUser(profile()->GetProfileName()); | 2191 SwitchActiveUser(profile()->GetProfileName()); |
2192 EXPECT_EQ(3, model_->item_count()); | 2192 EXPECT_EQ(3, model_->item_count()); |
2193 } | 2193 } |
2194 | 2194 |
2195 // Check that V2 applications are creating items properly in edge cases: | 2195 // Check that V2 applications are creating items properly in edge cases: |
2196 // a background user creates a V2 app, gets active and inactive again and then | 2196 // a background user creates a V2 app, gets active and inactive again and then |
2197 // deletes the app. | 2197 // deletes the app. |
2198 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2198 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
2199 V2AppHandlingTwoUsersEdgeCases) { | 2199 V2AppHandlingTwoUsersEdgeCases) { |
2200 InitLauncherController(); | 2200 InitLauncherController(); |
2201 // Create a profile for our second user (will be destroyed by the framework). | 2201 // Create a profile for our second user (will be destroyed by the framework). |
2202 TestingProfile* profile2 = CreateMultiUserProfile("user2"); | 2202 TestingProfile* profile2 = CreateMultiUserProfile("user2"); |
2203 // Check that there is a browser and a app launcher. | 2203 // Check that there is a browser and a app launcher. |
2204 EXPECT_EQ(2, model_->item_count()); | 2204 EXPECT_EQ(2, model_->item_count()); |
2205 | 2205 |
2206 // Switch to an inactive user. | 2206 // Switch to an inactive user. |
2207 SwitchActiveUser(profile2->GetProfileName()); | 2207 SwitchActiveUser(profile2->GetProfileName()); |
2208 EXPECT_EQ(2, model_->item_count()); | 2208 EXPECT_EQ(2, model_->item_count()); |
2209 | 2209 |
2210 // Add the v2 app to the inactive user and check that no item was added to | 2210 // Add the v2 app to the inactive user and check that no item was added to |
2211 // the launcher. | 2211 // the launcher. |
2212 { | 2212 { |
2213 V2App v2_app(profile(), extension1_); | 2213 V2App v2_app(profile(), extension1_.get()); |
2214 EXPECT_EQ(2, model_->item_count()); | 2214 EXPECT_EQ(2, model_->item_count()); |
2215 | 2215 |
2216 // Switch to the primary user and check that the item is shown. | 2216 // Switch to the primary user and check that the item is shown. |
2217 SwitchActiveUser(profile()->GetProfileName()); | 2217 SwitchActiveUser(profile()->GetProfileName()); |
2218 EXPECT_EQ(3, model_->item_count()); | 2218 EXPECT_EQ(3, model_->item_count()); |
2219 | 2219 |
2220 // Switch to the second user and check that the item goes away - even if the | 2220 // Switch to the second user and check that the item goes away - even if the |
2221 // item gets closed. | 2221 // item gets closed. |
2222 SwitchActiveUser(profile2->GetProfileName()); | 2222 SwitchActiveUser(profile2->GetProfileName()); |
2223 EXPECT_EQ(2, model_->item_count()); | 2223 EXPECT_EQ(2, model_->item_count()); |
(...skipping 17 matching lines...) Expand all Loading... |
2241 chrome::MultiUserWindowManager::GetInstance(); | 2241 chrome::MultiUserWindowManager::GetInstance(); |
2242 | 2242 |
2243 // Create and add three users / profiles, and go to #1's desktop. | 2243 // Create and add three users / profiles, and go to #1's desktop. |
2244 TestingProfile* profile1 = CreateMultiUserProfile("user-1"); | 2244 TestingProfile* profile1 = CreateMultiUserProfile("user-1"); |
2245 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); | 2245 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); |
2246 TestingProfile* profile3 = CreateMultiUserProfile("user-3"); | 2246 TestingProfile* profile3 = CreateMultiUserProfile("user-3"); |
2247 SwitchActiveUser(profile1->GetProfileName()); | 2247 SwitchActiveUser(profile1->GetProfileName()); |
2248 | 2248 |
2249 // A v2 app for user #1 should be shown first and get hidden when switching to | 2249 // A v2 app for user #1 should be shown first and get hidden when switching to |
2250 // desktop #2. | 2250 // desktop #2. |
2251 V2App v2_app_1(profile1, extension1_); | 2251 V2App v2_app_1(profile1, extension1_.get()); |
2252 EXPECT_TRUE(v2_app_1.window()->GetNativeWindow()->IsVisible()); | 2252 EXPECT_TRUE(v2_app_1.window()->GetNativeWindow()->IsVisible()); |
2253 SwitchActiveUser(profile2->GetProfileName()); | 2253 SwitchActiveUser(profile2->GetProfileName()); |
2254 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); | 2254 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); |
2255 | 2255 |
2256 // Add a v2 app for user #1 while on desktop #2 should not be shown. | 2256 // Add a v2 app for user #1 while on desktop #2 should not be shown. |
2257 V2App v2_app_2(profile1, extension1_); | 2257 V2App v2_app_2(profile1, extension1_.get()); |
2258 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); | 2258 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); |
2259 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); | 2259 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); |
2260 | 2260 |
2261 // Teleport the app from user #1 to the desktop #2 should show it. | 2261 // Teleport the app from user #1 to the desktop #2 should show it. |
2262 manager->ShowWindowForUser(v2_app_1.window()->GetNativeWindow(), | 2262 manager->ShowWindowForUser(v2_app_1.window()->GetNativeWindow(), |
2263 profile2->GetProfileName()); | 2263 profile2->GetProfileName()); |
2264 EXPECT_TRUE(v2_app_1.window()->GetNativeWindow()->IsVisible()); | 2264 EXPECT_TRUE(v2_app_1.window()->GetNativeWindow()->IsVisible()); |
2265 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); | 2265 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); |
2266 | 2266 |
2267 // Creating a new application for user #1 on desktop #2 should teleport it | 2267 // Creating a new application for user #1 on desktop #2 should teleport it |
2268 // there automatically. | 2268 // there automatically. |
2269 V2App v2_app_3(profile1, extension1_); | 2269 V2App v2_app_3(profile1, extension1_.get()); |
2270 EXPECT_TRUE(v2_app_1.window()->GetNativeWindow()->IsVisible()); | 2270 EXPECT_TRUE(v2_app_1.window()->GetNativeWindow()->IsVisible()); |
2271 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); | 2271 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); |
2272 EXPECT_TRUE(v2_app_3.window()->GetNativeWindow()->IsVisible()); | 2272 EXPECT_TRUE(v2_app_3.window()->GetNativeWindow()->IsVisible()); |
2273 | 2273 |
2274 // Switching back to desktop#1 and creating an app for user #1 should move | 2274 // Switching back to desktop#1 and creating an app for user #1 should move |
2275 // the app on desktop #1. | 2275 // the app on desktop #1. |
2276 SwitchActiveUser(profile1->GetProfileName()); | 2276 SwitchActiveUser(profile1->GetProfileName()); |
2277 V2App v2_app_4(profile1, extension1_); | 2277 V2App v2_app_4(profile1, extension1_.get()); |
2278 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); | 2278 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); |
2279 EXPECT_TRUE(v2_app_2.window()->GetNativeWindow()->IsVisible()); | 2279 EXPECT_TRUE(v2_app_2.window()->GetNativeWindow()->IsVisible()); |
2280 EXPECT_FALSE(v2_app_3.window()->GetNativeWindow()->IsVisible()); | 2280 EXPECT_FALSE(v2_app_3.window()->GetNativeWindow()->IsVisible()); |
2281 EXPECT_TRUE(v2_app_4.window()->GetNativeWindow()->IsVisible()); | 2281 EXPECT_TRUE(v2_app_4.window()->GetNativeWindow()->IsVisible()); |
2282 | 2282 |
2283 // Switching to desktop #3 and create an app for user #1 there should land on | 2283 // Switching to desktop #3 and create an app for user #1 there should land on |
2284 // his own desktop (#1). | 2284 // his own desktop (#1). |
2285 SwitchActiveUser(profile3->GetProfileName()); | 2285 SwitchActiveUser(profile3->GetProfileName()); |
2286 V2App v2_app_5(profile1, extension1_); | 2286 V2App v2_app_5(profile1, extension1_.get()); |
2287 EXPECT_FALSE(v2_app_5.window()->GetNativeWindow()->IsVisible()); | 2287 EXPECT_FALSE(v2_app_5.window()->GetNativeWindow()->IsVisible()); |
2288 SwitchActiveUser(profile1->GetProfileName()); | 2288 SwitchActiveUser(profile1->GetProfileName()); |
2289 EXPECT_TRUE(v2_app_5.window()->GetNativeWindow()->IsVisible()); | 2289 EXPECT_TRUE(v2_app_5.window()->GetNativeWindow()->IsVisible()); |
2290 | 2290 |
2291 // Switching to desktop #2, hiding the app window and creating an app should | 2291 // Switching to desktop #2, hiding the app window and creating an app should |
2292 // teleport there automatically. | 2292 // teleport there automatically. |
2293 SwitchActiveUser(profile2->GetProfileName()); | 2293 SwitchActiveUser(profile2->GetProfileName()); |
2294 v2_app_1.window()->Hide(); | 2294 v2_app_1.window()->Hide(); |
2295 V2App v2_app_6(profile1, extension1_); | 2295 V2App v2_app_6(profile1, extension1_.get()); |
2296 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); | 2296 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); |
2297 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); | 2297 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); |
2298 EXPECT_TRUE(v2_app_6.window()->GetNativeWindow()->IsVisible()); | 2298 EXPECT_TRUE(v2_app_6.window()->GetNativeWindow()->IsVisible()); |
2299 } | 2299 } |
2300 | 2300 |
2301 // Check that V2 applications hide correctly on the shelf when the app window | 2301 // Check that V2 applications hide correctly on the shelf when the app window |
2302 // is hidden. | 2302 // is hidden. |
2303 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2303 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
2304 V2AppHiddenWindows) { | 2304 V2AppHiddenWindows) { |
2305 InitLauncherController(); | 2305 InitLauncherController(); |
2306 | 2306 |
2307 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); | 2307 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); |
2308 SwitchActiveUser(profile()->GetProfileName()); | 2308 SwitchActiveUser(profile()->GetProfileName()); |
2309 EXPECT_EQ(2, model_->item_count()); | 2309 EXPECT_EQ(2, model_->item_count()); |
2310 | 2310 |
2311 V2App v2_app_1(profile(), extension1_); | 2311 V2App v2_app_1(profile(), extension1_.get()); |
2312 EXPECT_EQ(3, model_->item_count()); | 2312 EXPECT_EQ(3, model_->item_count()); |
2313 { | 2313 { |
2314 // Hide and show the app. | 2314 // Hide and show the app. |
2315 v2_app_1.window()->Hide(); | 2315 v2_app_1.window()->Hide(); |
2316 EXPECT_EQ(2, model_->item_count()); | 2316 EXPECT_EQ(2, model_->item_count()); |
2317 | 2317 |
2318 v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE); | 2318 v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE); |
2319 EXPECT_EQ(3, model_->item_count()); | 2319 EXPECT_EQ(3, model_->item_count()); |
2320 } | 2320 } |
2321 { | 2321 { |
(...skipping 19 matching lines...) Expand all Loading... |
2341 EXPECT_EQ(2, model_->item_count()); | 2341 EXPECT_EQ(2, model_->item_count()); |
2342 | 2342 |
2343 SwitchActiveUser(profile()->GetProfileName()); | 2343 SwitchActiveUser(profile()->GetProfileName()); |
2344 EXPECT_EQ(2, model_->item_count()); | 2344 EXPECT_EQ(2, model_->item_count()); |
2345 | 2345 |
2346 v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE); | 2346 v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE); |
2347 EXPECT_EQ(3, model_->item_count()); | 2347 EXPECT_EQ(3, model_->item_count()); |
2348 } | 2348 } |
2349 { | 2349 { |
2350 // Create a second app, hide and show it and then hide both apps. | 2350 // Create a second app, hide and show it and then hide both apps. |
2351 V2App v2_app_2(profile(), extension1_); | 2351 V2App v2_app_2(profile(), extension1_.get()); |
2352 EXPECT_EQ(3, model_->item_count()); | 2352 EXPECT_EQ(3, model_->item_count()); |
2353 | 2353 |
2354 v2_app_2.window()->Hide(); | 2354 v2_app_2.window()->Hide(); |
2355 EXPECT_EQ(3, model_->item_count()); | 2355 EXPECT_EQ(3, model_->item_count()); |
2356 | 2356 |
2357 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE); | 2357 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE); |
2358 EXPECT_EQ(3, model_->item_count()); | 2358 EXPECT_EQ(3, model_->item_count()); |
2359 | 2359 |
2360 v2_app_1.window()->Hide(); | 2360 v2_app_1.window()->Hide(); |
2361 v2_app_2.window()->Hide(); | 2361 v2_app_2.window()->Hide(); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2683 | 2683 |
2684 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2684 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
2685 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2685 ASSERT_EQ(initial_size + 1, model_->items().size()); |
2686 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2686 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
2687 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2687 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
2688 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2688 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
2689 | 2689 |
2690 launcher_controller_->UnpinAppWithID("1"); | 2690 launcher_controller_->UnpinAppWithID("1"); |
2691 ASSERT_EQ(initial_size, model_->items().size()); | 2691 ASSERT_EQ(initial_size, model_->items().size()); |
2692 } | 2692 } |
OLD | NEW |