| 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/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 } // namespace mojo | 52 } // namespace mojo |
| 53 | 53 |
| 54 namespace { | 54 namespace { |
| 55 | 55 |
| 56 constexpr char kTestAppName[] = "Test Arc App"; | 56 constexpr char kTestAppName[] = "Test Arc App"; |
| 57 constexpr char kTestAppName2[] = "Test Arc App 2"; | 57 constexpr char kTestAppName2[] = "Test Arc App 2"; |
| 58 constexpr char kTestShortcutName[] = "Test Shortcut"; | 58 constexpr char kTestShortcutName[] = "Test Shortcut"; |
| 59 constexpr char kTestShortcutName2[] = "Test Shortcut 2"; | 59 constexpr char kTestShortcutName2[] = "Test Shortcut 2"; |
| 60 constexpr char kTestAppPackage[] = "test.arc.app.package"; | 60 constexpr char kTestAppPackage[] = "test.arc.app.package"; |
| 61 constexpr char kTestAppPackage2[] = "test.arc.app.package2"; |
| 62 constexpr char kTestAppPackage3[] = "test.arc.app.package3"; |
| 61 constexpr char kTestAppActivity[] = "test.arc.app.package.activity"; | 63 constexpr char kTestAppActivity[] = "test.arc.app.package.activity"; |
| 62 constexpr char kTestAppActivity2[] = "test.arc.gitapp.package.activity2"; | 64 constexpr char kTestAppActivity2[] = "test.arc.gitapp.package.activity2"; |
| 63 constexpr char kTestShelfGroup[] = "shelf_group"; | 65 constexpr char kTestShelfGroup[] = "shelf_group"; |
| 64 constexpr char kTestShelfGroup2[] = "shelf_group_2"; | 66 constexpr char kTestShelfGroup2[] = "shelf_group_2"; |
| 65 constexpr char kTestShelfGroup3[] = "shelf_group_3"; | 67 constexpr char kTestShelfGroup3[] = "shelf_group_3"; |
| 66 constexpr int kAppAnimatedThresholdMs = 100; | 68 constexpr int kAppAnimatedThresholdMs = 100; |
| 67 | 69 |
| 68 std::string GetTestApp1Id() { | 70 std::string GetTestApp1Id(const std::string& package_name) { |
| 69 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity); | 71 return ArcAppListPrefs::GetAppId(package_name, kTestAppActivity); |
| 70 } | 72 } |
| 71 | 73 |
| 72 std::string GetTestApp2Id() { | 74 std::string GetTestApp2Id(const std::string& package_name) { |
| 73 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity2); | 75 return ArcAppListPrefs::GetAppId(package_name, kTestAppActivity2); |
| 74 } | 76 } |
| 75 | 77 |
| 76 std::vector<arc::mojom::AppInfoPtr> GetTestAppsList(bool multi_app) { | 78 std::vector<arc::mojom::AppInfoPtr> GetTestAppsList( |
| 79 const std::string& package_name, |
| 80 bool multi_app) { |
| 77 std::vector<arc::mojom::AppInfoPtr> apps; | 81 std::vector<arc::mojom::AppInfoPtr> apps; |
| 78 | 82 |
| 79 arc::mojom::AppInfoPtr app(arc::mojom::AppInfo::New()); | 83 arc::mojom::AppInfoPtr app(arc::mojom::AppInfo::New()); |
| 80 app->name = kTestAppName; | 84 app->name = kTestAppName; |
| 81 app->package_name = kTestAppPackage; | 85 app->package_name = package_name; |
| 82 app->activity = kTestAppActivity; | 86 app->activity = kTestAppActivity; |
| 83 app->sticky = false; | 87 app->sticky = false; |
| 84 apps.push_back(std::move(app)); | 88 apps.push_back(std::move(app)); |
| 85 | 89 |
| 86 if (multi_app) { | 90 if (multi_app) { |
| 87 app = arc::mojom::AppInfo::New(); | 91 app = arc::mojom::AppInfo::New(); |
| 88 app->name = kTestAppName2; | 92 app->name = kTestAppName2; |
| 89 app->package_name = kTestAppPackage; | 93 app->package_name = package_name; |
| 90 app->activity = kTestAppActivity2; | 94 app->activity = kTestAppActivity2; |
| 91 app->sticky = false; | 95 app->sticky = false; |
| 92 apps.push_back(std::move(app)); | 96 apps.push_back(std::move(app)); |
| 93 } | 97 } |
| 94 | 98 |
| 95 return apps; | 99 return apps; |
| 96 } | 100 } |
| 97 | 101 |
| 98 ChromeLauncherController* chrome_controller() { | 102 ChromeLauncherController* chrome_controller() { |
| 99 return ChromeLauncherController::instance(); | 103 return ChromeLauncherController::instance(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 162 |
| 159 void SetUpInProcessBrowserTestFixture() override { | 163 void SetUpInProcessBrowserTestFixture() override { |
| 160 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); | 164 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 161 arc::ArcSessionManager::DisableUIForTesting(); | 165 arc::ArcSessionManager::DisableUIForTesting(); |
| 162 } | 166 } |
| 163 | 167 |
| 164 void SetUpOnMainThread() override { | 168 void SetUpOnMainThread() override { |
| 165 arc::ArcSessionManager::Get()->EnableArc(); | 169 arc::ArcSessionManager::Get()->EnableArc(); |
| 166 } | 170 } |
| 167 | 171 |
| 168 void InstallTestApps(bool multi_app) { | 172 void InstallTestApps(const std::string& package_name, bool multi_app) { |
| 169 app_host()->OnAppListRefreshed(GetTestAppsList(multi_app)); | 173 app_host()->OnAppListRefreshed(GetTestAppsList(package_name, multi_app)); |
| 170 | 174 |
| 171 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | 175 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
| 172 app_prefs()->GetApp(GetTestApp1Id()); | 176 app_prefs()->GetApp(GetTestApp1Id(package_name)); |
| 173 ASSERT_TRUE(app_info); | 177 ASSERT_TRUE(app_info); |
| 174 EXPECT_TRUE(app_info->ready); | 178 EXPECT_TRUE(app_info->ready); |
| 175 if (multi_app) { | 179 if (multi_app) { |
| 176 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info2 = | 180 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info2 = |
| 177 app_prefs()->GetApp(GetTestApp2Id()); | 181 app_prefs()->GetApp(GetTestApp2Id(package_name)); |
| 178 ASSERT_TRUE(app_info2); | 182 ASSERT_TRUE(app_info2); |
| 179 EXPECT_TRUE(app_info2->ready); | 183 EXPECT_TRUE(app_info2->ready); |
| 180 } | 184 } |
| 181 } | 185 } |
| 182 | 186 |
| 183 std::string InstallShortcut(const std::string& name, | 187 std::string InstallShortcut(const std::string& name, |
| 184 const std::string& shelf_group) { | 188 const std::string& shelf_group) { |
| 185 arc::mojom::ShortcutInfo shortcut; | 189 arc::mojom::ShortcutInfo shortcut; |
| 186 shortcut.name = name; | 190 shortcut.name = name; |
| 187 shortcut.package_name = kTestAppPackage; | 191 shortcut.package_name = kTestAppPackage; |
| 188 shortcut.intent_uri = CreateIntentUriWithShelfGroup(shelf_group); | 192 shortcut.intent_uri = CreateIntentUriWithShelfGroup(shelf_group); |
| 189 const std::string shortcut_id = | 193 const std::string shortcut_id = |
| 190 ArcAppListPrefs::GetAppId(shortcut.package_name, shortcut.intent_uri); | 194 ArcAppListPrefs::GetAppId(shortcut.package_name, shortcut.intent_uri); |
| 191 app_host()->OnInstallShortcut(arc::mojom::ShortcutInfo::From(shortcut)); | 195 app_host()->OnInstallShortcut(arc::mojom::ShortcutInfo::From(shortcut)); |
| 192 base::RunLoop().RunUntilIdle(); | 196 base::RunLoop().RunUntilIdle(); |
| 193 | 197 |
| 194 std::unique_ptr<ArcAppListPrefs::AppInfo> shortcut_info = | 198 std::unique_ptr<ArcAppListPrefs::AppInfo> shortcut_info = |
| 195 app_prefs()->GetApp(shortcut_id); | 199 app_prefs()->GetApp(shortcut_id); |
| 196 | 200 |
| 197 CHECK(shortcut_info); | 201 CHECK(shortcut_info); |
| 198 EXPECT_TRUE(shortcut_info->shortcut); | 202 EXPECT_TRUE(shortcut_info->shortcut); |
| 199 EXPECT_EQ(kTestAppPackage, shortcut_info->package_name); | 203 EXPECT_EQ(kTestAppPackage, shortcut_info->package_name); |
| 200 EXPECT_EQ(shortcut.intent_uri, shortcut_info->intent_uri); | 204 EXPECT_EQ(shortcut.intent_uri, shortcut_info->intent_uri); |
| 201 return shortcut_id; | 205 return shortcut_id; |
| 202 } | 206 } |
| 203 | 207 |
| 204 void SendPackageAdded(bool package_synced) { | 208 void SendPackageAdded(const std::string& package_name, bool package_synced) { |
| 205 arc::mojom::ArcPackageInfo package_info; | 209 arc::mojom::ArcPackageInfo package_info; |
| 206 package_info.package_name = kTestAppPackage; | 210 package_info.package_name = package_name; |
| 207 package_info.package_version = 1; | 211 package_info.package_version = 1; |
| 208 package_info.last_backup_android_id = 1; | 212 package_info.last_backup_android_id = 1; |
| 209 package_info.last_backup_time = 1; | 213 package_info.last_backup_time = 1; |
| 210 package_info.sync = package_synced; | 214 package_info.sync = package_synced; |
| 211 package_info.system = false; | 215 package_info.system = false; |
| 212 app_host()->OnPackageAdded(arc::mojom::ArcPackageInfo::From(package_info)); | 216 app_host()->OnPackageAdded(arc::mojom::ArcPackageInfo::From(package_info)); |
| 213 | 217 |
| 214 base::RunLoop().RunUntilIdle(); | 218 base::RunLoop().RunUntilIdle(); |
| 215 } | 219 } |
| 216 | 220 |
| 217 void SendPackageUpdated(bool multi_app) { | 221 void SendPackageUpdated(const std::string& package_name, bool multi_app) { |
| 218 app_host()->OnPackageAppListRefreshed(kTestAppPackage, | 222 app_host()->OnPackageAppListRefreshed( |
| 219 GetTestAppsList(multi_app)); | 223 package_name, GetTestAppsList(package_name, multi_app)); |
| 220 } | 224 } |
| 221 | 225 |
| 222 void SendPackageRemoved() { app_host()->OnPackageRemoved(kTestAppPackage); } | 226 void SendPackageRemoved(const std::string& package_name) { |
| 227 app_host()->OnPackageRemoved(package_name); |
| 228 } |
| 229 |
| 230 void SendInstallationStarted() { |
| 231 app_host()->OnInstallationStarted(); |
| 232 base::RunLoop().RunUntilIdle(); |
| 233 } |
| 234 |
| 235 void SendInstallationFinished() { |
| 236 app_host()->OnInstallationFinished(); |
| 237 base::RunLoop().RunUntilIdle(); |
| 238 } |
| 223 | 239 |
| 224 void StartInstance() { | 240 void StartInstance() { |
| 225 if (arc_session_manager()->profile() != profile()) | 241 if (arc_session_manager()->profile() != profile()) |
| 226 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 242 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 227 app_instance_observer()->OnInstanceReady(); | 243 app_instance_observer()->OnInstanceReady(); |
| 228 } | 244 } |
| 229 | 245 |
| 230 void StopInstance() { | 246 void StopInstance() { |
| 231 arc_session_manager()->Shutdown(); | 247 arc_session_manager()->Shutdown(); |
| 232 app_instance_observer()->OnInstanceClosed(); | 248 app_instance_observer()->OnInstanceClosed(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 TestAction test_action() const { return std::tr1::get<0>(GetParam()); } | 289 TestAction test_action() const { return std::tr1::get<0>(GetParam()); } |
| 274 | 290 |
| 275 private: | 291 private: |
| 276 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherBrowserTest); | 292 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherBrowserTest); |
| 277 }; | 293 }; |
| 278 | 294 |
| 279 // This tests simulates normal workflow for starting Arc app in deferred mode. | 295 // This tests simulates normal workflow for starting Arc app in deferred mode. |
| 280 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) { | 296 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) { |
| 281 // Install app to remember existing apps. | 297 // Install app to remember existing apps. |
| 282 StartInstance(); | 298 StartInstance(); |
| 283 InstallTestApps(false); | 299 InstallTestApps(kTestAppPackage, false); |
| 284 SendPackageAdded(false); | 300 SendPackageAdded(kTestAppPackage, false); |
| 285 | 301 |
| 286 const std::string app_id = GetTestApp1Id(); | 302 const std::string app_id = GetTestApp1Id(kTestAppPackage); |
| 287 if (is_pinned()) { | 303 if (is_pinned()) { |
| 288 shelf_delegate()->PinAppWithID(app_id); | 304 shelf_delegate()->PinAppWithID(app_id); |
| 289 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 305 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
| 290 } else { | 306 } else { |
| 291 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 307 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
| 292 } | 308 } |
| 293 | 309 |
| 294 StopInstance(); | 310 StopInstance(); |
| 295 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | 311 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
| 296 app_prefs()->GetApp(app_id); | 312 app_prefs()->GetApp(app_id); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 309 | 325 |
| 310 // Launching non-ready Arc app creates item on shelf and spinning animation. | 326 // Launching non-ready Arc app creates item on shelf and spinning animation. |
| 311 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); | 327 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); |
| 312 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 328 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
| 313 AppAnimatedWaiter(app_id).Wait(); | 329 AppAnimatedWaiter(app_id).Wait(); |
| 314 | 330 |
| 315 switch (test_action()) { | 331 switch (test_action()) { |
| 316 case TEST_ACTION_START: | 332 case TEST_ACTION_START: |
| 317 // Now simulates that Arc is started and app list is refreshed. This | 333 // Now simulates that Arc is started and app list is refreshed. This |
| 318 // should stop animation and delete icon from the shelf. | 334 // should stop animation and delete icon from the shelf. |
| 319 InstallTestApps(false); | 335 InstallTestApps(kTestAppPackage, false); |
| 320 SendPackageAdded(false); | 336 SendPackageAdded(kTestAppPackage, false); |
| 321 EXPECT_TRUE(chrome_controller() | 337 EXPECT_TRUE(chrome_controller() |
| 322 ->GetArcDeferredLauncher() | 338 ->GetArcDeferredLauncher() |
| 323 ->GetActiveTime(app_id) | 339 ->GetActiveTime(app_id) |
| 324 .is_zero()); | 340 .is_zero()); |
| 325 if (is_pinned()) | 341 if (is_pinned()) |
| 326 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 342 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
| 327 else | 343 else |
| 328 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 344 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
| 329 break; | 345 break; |
| 330 case TEST_ACTION_EXIT: | 346 case TEST_ACTION_EXIT: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 354 ::testing::ValuesIn(build_test_parameter)); | 370 ::testing::ValuesIn(build_test_parameter)); |
| 355 | 371 |
| 356 // This tests validates pin state on package update and remove. | 372 // This tests validates pin state on package update and remove. |
| 357 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) { | 373 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) { |
| 358 StartInstance(); | 374 StartInstance(); |
| 359 | 375 |
| 360 // Make use app list sync service is started. Normally it is started when | 376 // Make use app list sync service is started. Normally it is started when |
| 361 // sycing is initialized. | 377 // sycing is initialized. |
| 362 app_list::AppListSyncableServiceFactory::GetForProfile(profile())->GetModel(); | 378 app_list::AppListSyncableServiceFactory::GetForProfile(profile())->GetModel(); |
| 363 | 379 |
| 364 InstallTestApps(true); | 380 InstallTestApps(kTestAppPackage, true); |
| 365 SendPackageAdded(false); | 381 SendPackageAdded(kTestAppPackage, false); |
| 366 | 382 |
| 367 const std::string app_id1 = GetTestApp1Id(); | 383 const std::string app_id1 = GetTestApp1Id(kTestAppPackage); |
| 368 const std::string app_id2 = GetTestApp2Id(); | 384 const std::string app_id2 = GetTestApp2Id(kTestAppPackage); |
| 369 shelf_delegate()->PinAppWithID(app_id1); | 385 shelf_delegate()->PinAppWithID(app_id1); |
| 370 shelf_delegate()->PinAppWithID(app_id2); | 386 shelf_delegate()->PinAppWithID(app_id2); |
| 371 const ash::ShelfID shelf_id1_before = | 387 const ash::ShelfID shelf_id1_before = |
| 372 shelf_delegate()->GetShelfIDForAppID(app_id1); | 388 shelf_delegate()->GetShelfIDForAppID(app_id1); |
| 373 EXPECT_TRUE(shelf_id1_before); | 389 EXPECT_TRUE(shelf_id1_before); |
| 374 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 390 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id2)); |
| 375 | 391 |
| 376 // Package contains only one app. App list is not shown for updated package. | 392 // Package contains only one app. App list is not shown for updated package. |
| 377 SendPackageUpdated(false); | 393 SendPackageUpdated(kTestAppPackage, false); |
| 378 // Second pin should gone. | 394 // Second pin should gone. |
| 379 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); | 395 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); |
| 380 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 396 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); |
| 381 | 397 |
| 382 // Package contains two apps. App list is not shown for updated package. | 398 // Package contains two apps. App list is not shown for updated package. |
| 383 SendPackageUpdated(true); | 399 SendPackageUpdated(kTestAppPackage, true); |
| 384 // Second pin should not appear. | 400 // Second pin should not appear. |
| 385 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); | 401 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); |
| 386 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 402 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); |
| 387 | 403 |
| 388 // Package removed. | 404 // Package removed. |
| 389 SendPackageRemoved(); | 405 SendPackageRemoved(kTestAppPackage); |
| 390 // No pin is expected. | 406 // No pin is expected. |
| 391 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id1)); | 407 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id1)); |
| 392 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 408 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); |
| 393 } | 409 } |
| 394 | 410 |
| 395 // This test validates that app list is shown on new package and not shown | 411 // This test validates that app list is shown on new package and not shown |
| 396 // on package update. | 412 // on package update. |
| 397 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, AppListShown) { | 413 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, AppListShown) { |
| 398 StartInstance(); | 414 StartInstance(); |
| 399 AppListService* app_list_service = AppListService::Get(); | 415 AppListService* app_list_service = AppListService::Get(); |
| 400 ASSERT_TRUE(app_list_service); | 416 ASSERT_TRUE(app_list_service); |
| 401 | 417 |
| 402 EXPECT_FALSE(app_list_service->IsAppListVisible()); | 418 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 403 | 419 |
| 420 SendInstallationStarted(); |
| 421 SendInstallationStarted(); |
| 422 |
| 404 // New package is available. Show app list. | 423 // New package is available. Show app list. |
| 405 InstallTestApps(false); | 424 SendInstallationFinished(); |
| 406 SendPackageAdded(true); | 425 InstallTestApps(kTestAppPackage, false); |
| 426 SendPackageAdded(kTestAppPackage, true); |
| 407 EXPECT_TRUE(app_list_service->IsAppListVisible()); | 427 EXPECT_TRUE(app_list_service->IsAppListVisible()); |
| 408 | 428 |
| 409 app_list_service->DismissAppList(); | 429 app_list_service->DismissAppList(); |
| 410 EXPECT_FALSE(app_list_service->IsAppListVisible()); | 430 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 411 | 431 |
| 412 // Send package update event. App list is not shown. | 432 // Send package update event. App list is not shown. |
| 413 SendPackageAdded(true); | 433 SendPackageAdded(kTestAppPackage, true); |
| 414 EXPECT_FALSE(app_list_service->IsAppListVisible()); | 434 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 435 |
| 436 // Install next package from batch. Next new package is available. |
| 437 // Don't show app list. |
| 438 SendInstallationFinished(); |
| 439 InstallTestApps(kTestAppPackage2, false); |
| 440 SendPackageAdded(kTestAppPackage2, true); |
| 441 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 442 |
| 443 // Run next installation batch. App list should be shown again. |
| 444 SendInstallationStarted(); |
| 445 SendInstallationFinished(); |
| 446 InstallTestApps(kTestAppPackage3, false); |
| 447 SendPackageAdded(kTestAppPackage3, true); |
| 448 EXPECT_TRUE(app_list_service->IsAppListVisible()); |
| 449 app_list_service->DismissAppList(); |
| 415 } | 450 } |
| 416 | 451 |
| 417 // Test AppListControllerDelegate::IsAppOpen for Arc apps. | 452 // Test AppListControllerDelegate::IsAppOpen for Arc apps. |
| 418 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, IsAppOpen) { | 453 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, IsAppOpen) { |
| 419 StartInstance(); | 454 StartInstance(); |
| 420 InstallTestApps(false); | 455 InstallTestApps(kTestAppPackage, false); |
| 421 SendPackageAdded(true); | 456 SendPackageAdded(kTestAppPackage, true); |
| 422 const std::string app_id = GetTestApp1Id(); | 457 const std::string app_id = GetTestApp1Id(kTestAppPackage); |
| 423 | 458 |
| 424 AppListService* service = AppListService::Get(); | 459 AppListService* service = AppListService::Get(); |
| 425 AppListControllerDelegate* delegate = service->GetControllerDelegate(); | 460 AppListControllerDelegate* delegate = service->GetControllerDelegate(); |
| 426 EXPECT_FALSE(delegate->IsAppOpen(app_id)); | 461 EXPECT_FALSE(delegate->IsAppOpen(app_id)); |
| 427 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); | 462 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); |
| 428 EXPECT_FALSE(delegate->IsAppOpen(app_id)); | 463 EXPECT_FALSE(delegate->IsAppOpen(app_id)); |
| 429 // Simulate task creation so the app is marked as running/open. | 464 // Simulate task creation so the app is marked as running/open. |
| 430 std::unique_ptr<ArcAppListPrefs::AppInfo> info = app_prefs()->GetApp(app_id); | 465 std::unique_ptr<ArcAppListPrefs::AppInfo> info = app_prefs()->GetApp(app_id); |
| 431 app_host()->OnTaskCreated(0, info->package_name, info->activity, info->name, | 466 app_host()->OnTaskCreated(0, info->package_name, info->activity, info->name, |
| 432 info->intent_uri); | 467 info->intent_uri); |
| 433 EXPECT_TRUE(delegate->IsAppOpen(app_id)); | 468 EXPECT_TRUE(delegate->IsAppOpen(app_id)); |
| 434 } | 469 } |
| 435 | 470 |
| 436 // Test Shelf Groups | 471 // Test Shelf Groups |
| 437 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, ShelfGroup) { | 472 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, ShelfGroup) { |
| 438 StartInstance(); | 473 StartInstance(); |
| 439 InstallTestApps(false); | 474 InstallTestApps(kTestAppPackage, false); |
| 440 SendPackageAdded(true); | 475 SendPackageAdded(kTestAppPackage, true); |
| 441 const std::string shorcut_id1 = | 476 const std::string shorcut_id1 = |
| 442 InstallShortcut(kTestShortcutName, kTestShelfGroup); | 477 InstallShortcut(kTestShortcutName, kTestShelfGroup); |
| 443 const std::string shorcut_id2 = | 478 const std::string shorcut_id2 = |
| 444 InstallShortcut(kTestShortcutName2, kTestShelfGroup2); | 479 InstallShortcut(kTestShortcutName2, kTestShelfGroup2); |
| 445 | 480 |
| 446 const std::string app_id = GetTestApp1Id(); | 481 const std::string app_id = GetTestApp1Id(kTestAppPackage); |
| 447 std::unique_ptr<ArcAppListPrefs::AppInfo> info = app_prefs()->GetApp(app_id); | 482 std::unique_ptr<ArcAppListPrefs::AppInfo> info = app_prefs()->GetApp(app_id); |
| 448 ASSERT_TRUE(info); | 483 ASSERT_TRUE(info); |
| 449 | 484 |
| 450 const std::string shelf_id1 = | 485 const std::string shelf_id1 = |
| 451 arc::ArcAppShelfId(kTestShelfGroup, app_id).ToString(); | 486 arc::ArcAppShelfId(kTestShelfGroup, app_id).ToString(); |
| 452 const std::string shelf_id2 = | 487 const std::string shelf_id2 = |
| 453 arc::ArcAppShelfId(kTestShelfGroup2, app_id).ToString(); | 488 arc::ArcAppShelfId(kTestShelfGroup2, app_id).ToString(); |
| 454 const std::string shelf_id3 = | 489 const std::string shelf_id3 = |
| 455 arc::ArcAppShelfId(kTestShelfGroup3, app_id).ToString(); | 490 arc::ArcAppShelfId(kTestShelfGroup3, app_id).ToString(); |
| 456 | 491 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 app_host()->OnTaskDestroyed(2); | 531 app_host()->OnTaskDestroyed(2); |
| 497 EXPECT_EQ(controller2, GetAppItemController(shelf_id2)); | 532 EXPECT_EQ(controller2, GetAppItemController(shelf_id2)); |
| 498 // Destroy task #2, this kills shelf group 2 | 533 // Destroy task #2, this kills shelf group 2 |
| 499 app_host()->OnTaskDestroyed(3); | 534 app_host()->OnTaskDestroyed(3); |
| 500 EXPECT_FALSE(GetAppItemController(shelf_id2)); | 535 EXPECT_FALSE(GetAppItemController(shelf_id2)); |
| 501 | 536 |
| 502 // Disable Arc, this removes app and as result kills shelf group 3. | 537 // Disable Arc, this removes app and as result kills shelf group 3. |
| 503 arc::ArcSessionManager::Get()->DisableArc(); | 538 arc::ArcSessionManager::Get()->DisableArc(); |
| 504 EXPECT_FALSE(GetAppItemController(shelf_id3)); | 539 EXPECT_FALSE(GetAppItemController(shelf_id3)); |
| 505 } | 540 } |
| OLD | NEW |