Chromium Code Reviews| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 base::Bind(arc::FakeArcSession::Create))); | 88 base::Bind(arc::FakeArcSession::Create))); |
| 89 DCHECK(arc::ArcSessionManager::Get()); | 89 DCHECK(arc::ArcSessionManager::Get()); |
| 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 if (wait_default_apps_) |
| 99 DCHECK(arc_app_list_pref_); | 99 WaitForDefaultApps(); |
| 100 base::RunLoop run_loop; | |
| 101 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); | |
| 102 run_loop.Run(); | |
| 103 | 100 |
| 104 // Check initial conditions. | 101 // Check initial conditions. |
| 105 if (arc::ShouldArcAlwaysStart()) { | 102 if (arc::ShouldArcAlwaysStart()) { |
| 106 // When ARC first starts, it runs in opt-out mode of Play Store. | 103 // When ARC first starts, it runs in opt-out mode of Play Store. |
| 107 EXPECT_TRUE(arc_session_manager_->IsSessionRunning()); | 104 EXPECT_TRUE(arc_session_manager_->IsSessionRunning()); |
| 108 } else { | 105 } else { |
| 109 arc::SetArcPlayStoreEnabledForProfile(profile_, true); | 106 arc::SetArcPlayStoreEnabledForProfile(profile_, true); |
| 110 EXPECT_FALSE(arc_session_manager_->IsSessionRunning()); | 107 EXPECT_FALSE(arc_session_manager_->IsSessionRunning()); |
| 111 } | 108 } |
| 112 | 109 |
| 110 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | |
|
hidehiko
2017/03/16 16:23:19
Initializing twice looks not straightforward.
Cou
khmel
2017/03/16 16:38:47
Done.
| |
| 111 DCHECK(arc_app_list_pref_); | |
| 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 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | |
| 119 DCHECK(arc_app_list_pref_); | |
| 120 base::RunLoop run_loop; | |
| 121 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); | |
| 122 run_loop.Run(); | |
| 123 } | |
| 124 | |
| 118 void ArcAppTest::CreateFakeAppsAndPackages() { | 125 void ArcAppTest::CreateFakeAppsAndPackages() { |
| 119 arc::mojom::AppInfo app; | 126 arc::mojom::AppInfo app; |
| 120 // Make sure we have enough data for test. | 127 // Make sure we have enough data for test. |
| 121 for (int i = 0; i < 3; ++i) { | 128 for (int i = 0; i < 3; ++i) { |
| 122 app.name = base::StringPrintf("Fake App %d", i); | 129 app.name = base::StringPrintf("Fake App %d", i); |
| 123 app.package_name = base::StringPrintf("fake.app.%d", i); | 130 app.package_name = base::StringPrintf("fake.app.%d", i); |
| 124 app.activity = base::StringPrintf("fake.app.%d.activity", i); | 131 app.activity = base::StringPrintf("fake.app.%d.activity", i); |
| 125 app.sticky = false; | 132 app.sticky = false; |
| 126 fake_apps_.push_back(app); | 133 fake_apps_.push_back(app); |
| 127 } | 134 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 } | 231 } |
| 225 } | 232 } |
| 226 | 233 |
| 227 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { | 234 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { |
| 228 for (auto fake_package : fake_packages_) { | 235 for (auto fake_package : fake_packages_) { |
| 229 if (package.package_name == fake_package.package_name) | 236 if (package.package_name == fake_package.package_name) |
| 230 return true; | 237 return true; |
| 231 } | 238 } |
| 232 return false; | 239 return false; |
| 233 } | 240 } |
| OLD | NEW |