| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/common/shelf/shelf_delegate.h" | 5 #include "ash/common/shelf/shelf_delegate.h" |
| 6 #include "ash/common/wm_shell.h" | 6 #include "ash/common/wm_shell.h" |
| 7 #include "ash/shelf/shelf_util.h" | 7 #include "ash/shelf/shelf_util.h" |
| 8 #include "ash/wm/window_util.h" | 8 #include "ash/wm/window_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 }; | 217 }; |
| 218 | 218 |
| 219 // This tests simulates normal workflow for starting Arc app in deferred mode. | 219 // This tests simulates normal workflow for starting Arc app in deferred mode. |
| 220 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) { | 220 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) { |
| 221 // Install app to remember existing apps. | 221 // Install app to remember existing apps. |
| 222 InstallTestApps(false); | 222 InstallTestApps(false); |
| 223 | 223 |
| 224 const std::string app_id = GetTestApp1Id(); | 224 const std::string app_id = GetTestApp1Id(); |
| 225 if (is_pinned()) { | 225 if (is_pinned()) { |
| 226 shelf_delegate()->PinAppWithID(app_id); | 226 shelf_delegate()->PinAppWithID(app_id); |
| 227 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 227 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 228 } else { | 228 } else { |
| 229 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 229 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 230 } | 230 } |
| 231 | 231 |
| 232 StopInstance(); | 232 StopInstance(); |
| 233 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | 233 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
| 234 app_prefs()->GetApp(app_id); | 234 app_prefs()->GetApp(app_id); |
| 235 EXPECT_FALSE(app_info); | 235 EXPECT_FALSE(app_info); |
| 236 | 236 |
| 237 // Restart instance. App should be taken from prefs but its state is non-ready | 237 // Restart instance. App should be taken from prefs but its state is non-ready |
| 238 // currently. | 238 // currently. |
| 239 StartInstance(); | 239 StartInstance(); |
| 240 app_info = app_prefs()->GetApp(app_id); | 240 app_info = app_prefs()->GetApp(app_id); |
| 241 ASSERT_TRUE(app_info); | 241 ASSERT_TRUE(app_info); |
| 242 EXPECT_FALSE(app_info->ready); | 242 EXPECT_FALSE(app_info->ready); |
| 243 if (is_pinned()) | 243 if (is_pinned()) |
| 244 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 244 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 245 else | 245 else |
| 246 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 246 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 247 | 247 |
| 248 // Launching non-ready Arc app creates item on shelf and spinning animation. | 248 // Launching non-ready Arc app creates item on shelf and spinning animation. |
| 249 arc::LaunchApp(profile(), app_id); | 249 arc::LaunchApp(profile(), app_id); |
| 250 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 250 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 251 AppAnimatedWaiter(app_id).Wait(); | 251 AppAnimatedWaiter(app_id).Wait(); |
| 252 | 252 |
| 253 switch (test_action()) { | 253 switch (test_action()) { |
| 254 case TEST_ACTION_START: | 254 case TEST_ACTION_START: |
| 255 // Now simulates that Arc is started and app list is refreshed. This | 255 // Now simulates that Arc is started and app list is refreshed. This |
| 256 // should stop animation and delete icon from the shelf. | 256 // should stop animation and delete icon from the shelf. |
| 257 InstallTestApps(false); | 257 InstallTestApps(false); |
| 258 EXPECT_TRUE(chrome_controller() | 258 EXPECT_TRUE(chrome_controller() |
| 259 ->GetArcDeferredLauncher() | 259 ->GetArcDeferredLauncher() |
| 260 ->GetActiveTime(app_id) | 260 ->GetActiveTime(app_id) |
| 261 .is_zero()); | 261 .is_zero()); |
| 262 if (is_pinned()) | 262 if (is_pinned()) |
| 263 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 263 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 264 else | 264 else |
| 265 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 265 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 266 break; | 266 break; |
| 267 case TEST_ACTION_EXIT: | 267 case TEST_ACTION_EXIT: |
| 268 // Just exist Chrome. | 268 // Just exist Chrome. |
| 269 break; | 269 break; |
| 270 case TEST_ACTION_CLOSE: | 270 case TEST_ACTION_CLOSE: |
| 271 // Close item during animation. | 271 // Close item during animation. |
| 272 { | 272 { |
| 273 LauncherItemController* controller = | 273 LauncherItemController* controller = |
| 274 chrome_controller()->GetLauncherItemController( | 274 chrome_controller()->GetLauncherItemController( |
| 275 shelf_delegate()->GetShelfIDForAppID(app_id)); | 275 shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 276 ASSERT_TRUE(controller); | 276 ASSERT_TRUE(controller); |
| 277 controller->Close(); | 277 controller->Close(); |
| 278 EXPECT_TRUE(chrome_controller() | 278 EXPECT_TRUE(chrome_controller() |
| 279 ->GetArcDeferredLauncher() | 279 ->GetArcDeferredLauncher() |
| 280 ->GetActiveTime(app_id) | 280 ->GetActiveTime(app_id) |
| 281 .is_zero()); | 281 .is_zero()); |
| 282 if (is_pinned()) | 282 if (is_pinned()) |
| 283 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 283 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 284 else | 284 else |
| 285 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 285 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id, app_id)); |
| 286 } | 286 } |
| 287 break; | 287 break; |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 INSTANTIATE_TEST_CASE_P(ArcAppDeferredLauncherBrowserTestInstance, | 291 INSTANTIATE_TEST_CASE_P(ArcAppDeferredLauncherBrowserTestInstance, |
| 292 ArcAppDeferredLauncherBrowserTest, | 292 ArcAppDeferredLauncherBrowserTest, |
| 293 ::testing::ValuesIn(build_test_parameter)); | 293 ::testing::ValuesIn(build_test_parameter)); |
| 294 | 294 |
| 295 // This tests validates pin state on package update and remove. | 295 // This tests validates pin state on package update and remove. |
| 296 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) { | 296 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) { |
| 297 InstallTestApps(true); | 297 InstallTestApps(true); |
| 298 | 298 |
| 299 const std::string app_id1 = GetTestApp1Id(); | 299 const std::string app_id1 = GetTestApp1Id(); |
| 300 const std::string app_id2 = GetTestApp2Id(); | 300 const std::string app_id2 = GetTestApp2Id(); |
| 301 shelf_delegate()->PinAppWithID(app_id1); | 301 shelf_delegate()->PinAppWithID(app_id1); |
| 302 shelf_delegate()->PinAppWithID(app_id2); | 302 shelf_delegate()->PinAppWithID(app_id2); |
| 303 const ash::ShelfID shelf_id1_before = | 303 const ash::ShelfID shelf_id1_before = |
| 304 shelf_delegate()->GetShelfIDForAppID(app_id1); | 304 shelf_delegate()->GetShelfIDForAppID(app_id1, app_id1); |
| 305 EXPECT_TRUE(shelf_id1_before); | 305 EXPECT_TRUE(shelf_id1_before); |
| 306 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 306 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id2, app_id2)); |
| 307 | 307 |
| 308 // Package contains only one app. | 308 // Package contains only one app. |
| 309 SendPackageUpdated(false); | 309 SendPackageUpdated(false); |
| 310 // Second pin should gone. | 310 // Second pin should gone. |
| 311 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); | 311 EXPECT_EQ(shelf_id1_before, |
| 312 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 312 shelf_delegate()->GetShelfIDForAppID(app_id1, app_id1)); |
| 313 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2, app_id2)); |
| 313 | 314 |
| 314 // Package contains two apps. | 315 // Package contains two apps. |
| 315 SendPackageUpdated(true); | 316 SendPackageUpdated(true); |
| 316 // Second pin should not appear. | 317 // Second pin should not appear. |
| 317 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); | 318 EXPECT_EQ(shelf_id1_before, |
| 318 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 319 shelf_delegate()->GetShelfIDForAppID(app_id1, app_id1)); |
| 320 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2, app_id2)); |
| 319 | 321 |
| 320 // Package removed. | 322 // Package removed. |
| 321 SendPackageRemoved(); | 323 SendPackageRemoved(); |
| 322 // No pin is expected. | 324 // No pin is expected. |
| 323 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id1)); | 325 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id1, app_id1)); |
| 324 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 326 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2, app_id2)); |
| 325 } | 327 } |
| OLD | NEW |