| 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 "chrome/browser/ui/app_list/arc/arc_app_test.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 arc::ArcSessionManager::DisableUIForTesting(); | 90 arc::ArcSessionManager::DisableUIForTesting(); |
| 91 arc::ArcAuthNotification::DisableForTesting(); | 91 arc::ArcAuthNotification::DisableForTesting(); |
| 92 arc_session_manager_->SetProfile(profile_); | 92 arc_session_manager_->SetProfile(profile_); |
| 93 arc_play_store_enabled_preference_handler_ = | 93 arc_play_store_enabled_preference_handler_ = |
| 94 base::MakeUnique<arc::ArcPlayStoreEnabledPreferenceHandler>( | 94 base::MakeUnique<arc::ArcPlayStoreEnabledPreferenceHandler>( |
| 95 profile_, arc_session_manager_.get()); | 95 profile_, arc_session_manager_.get()); |
| 96 arc_play_store_enabled_preference_handler_->Start(); | 96 arc_play_store_enabled_preference_handler_->Start(); |
| 97 | 97 |
| 98 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | 98 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); |
| 99 DCHECK(arc_app_list_pref_); | 99 DCHECK(arc_app_list_pref_); |
| 100 base::RunLoop run_loop; | 100 if (wait_default_apps_) |
| 101 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); | 101 WaitForDefaultApps(); |
| 102 run_loop.Run(); | |
| 103 | 102 |
| 104 // Check initial conditions. | 103 // Check initial conditions. |
| 105 if (arc::ShouldArcAlwaysStart()) { | 104 if (arc::ShouldArcAlwaysStart()) { |
| 106 // When ARC first starts, it runs in opt-out mode of Play Store. | 105 // When ARC first starts, it runs in opt-out mode of Play Store. |
| 107 EXPECT_TRUE(arc_session_manager_->IsSessionRunning()); | 106 EXPECT_TRUE(arc_session_manager_->IsSessionRunning()); |
| 108 } else { | 107 } else { |
| 109 arc::SetArcPlayStoreEnabledForProfile(profile_, true); | 108 arc::SetArcPlayStoreEnabledForProfile(profile_, true); |
| 110 EXPECT_FALSE(arc_session_manager_->IsSessionRunning()); | 109 EXPECT_FALSE(arc_session_manager_->IsSessionRunning()); |
| 111 } | 110 } |
| 112 | 111 |
| 113 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); | 112 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); |
| 114 arc_service_manager_->arc_bridge_service()->app()->SetInstance( | 113 arc_service_manager_->arc_bridge_service()->app()->SetInstance( |
| 115 app_instance_.get()); | 114 app_instance_.get()); |
| 116 } | 115 } |
| 117 | 116 |
| 117 void ArcAppTest::WaitForDefaultApps() { |
| 118 DCHECK(arc_app_list_pref_); |
| 119 base::RunLoop run_loop; |
| 120 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
| 121 run_loop.Run(); |
| 122 } |
| 123 |
| 118 void ArcAppTest::CreateFakeAppsAndPackages() { | 124 void ArcAppTest::CreateFakeAppsAndPackages() { |
| 119 arc::mojom::AppInfo app; | 125 arc::mojom::AppInfo app; |
| 120 // Make sure we have enough data for test. | 126 // Make sure we have enough data for test. |
| 121 for (int i = 0; i < 3; ++i) { | 127 for (int i = 0; i < 3; ++i) { |
| 122 app.name = base::StringPrintf("Fake App %d", i); | 128 app.name = base::StringPrintf("Fake App %d", i); |
| 123 app.package_name = base::StringPrintf("fake.app.%d", i); | 129 app.package_name = base::StringPrintf("fake.app.%d", i); |
| 124 app.activity = base::StringPrintf("fake.app.%d.activity", i); | 130 app.activity = base::StringPrintf("fake.app.%d.activity", i); |
| 125 app.sticky = false; | 131 app.sticky = false; |
| 126 fake_apps_.push_back(app); | 132 fake_apps_.push_back(app); |
| 127 } | 133 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 230 } |
| 225 } | 231 } |
| 226 | 232 |
| 227 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { | 233 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { |
| 228 for (auto fake_package : fake_packages_) { | 234 for (auto fake_package : fake_packages_) { |
| 229 if (package.package_name == fake_package.package_name) | 235 if (package.package_name == fake_package.package_name) |
| 230 return true; | 236 return true; |
| 231 } | 237 } |
| 232 return false; | 238 return false; |
| 233 } | 239 } |
| OLD | NEW |