| 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" |
| 11 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" | 11 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" |
| 12 #include "chrome/browser/chromeos/arc/arc_play_store_enabled_preference_handler.
h" | 12 #include "chrome/browser/chromeos/arc/arc_play_store_enabled_preference_handler.
h" |
| 13 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 13 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 14 #include "chrome/browser/chromeos/arc/arc_util.h" | 14 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 15 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 19 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | 20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" |
| 21 #include "chromeos/chromeos_switches.h" |
| 21 #include "chromeos/dbus/dbus_thread_manager.h" | 22 #include "chromeos/dbus/dbus_thread_manager.h" |
| 22 #include "components/arc/arc_bridge_service.h" | 23 #include "components/arc/arc_bridge_service.h" |
| 23 #include "components/arc/arc_service_manager.h" | 24 #include "components/arc/arc_service_manager.h" |
| 24 #include "components/arc/arc_session_runner.h" | 25 #include "components/arc/arc_session_runner.h" |
| 25 #include "components/arc/arc_util.h" | 26 #include "components/arc/arc_util.h" |
| 26 #include "components/arc/test/fake_app_instance.h" | 27 #include "components/arc/test/fake_app_instance.h" |
| 27 #include "components/arc/test/fake_arc_session.h" | 28 #include "components/arc/test/fake_arc_session.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 base::MakeUnique<arc::ArcPlayStoreEnabledPreferenceHandler>( | 95 base::MakeUnique<arc::ArcPlayStoreEnabledPreferenceHandler>( |
| 95 profile_, arc_session_manager_.get()); | 96 profile_, arc_session_manager_.get()); |
| 96 arc_play_store_enabled_preference_handler_->Start(); | 97 arc_play_store_enabled_preference_handler_->Start(); |
| 97 | 98 |
| 98 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | 99 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); |
| 99 DCHECK(arc_app_list_pref_); | 100 DCHECK(arc_app_list_pref_); |
| 100 base::RunLoop run_loop; | 101 base::RunLoop run_loop; |
| 101 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); | 102 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
| 102 run_loop.Run(); | 103 run_loop.Run(); |
| 103 | 104 |
| 104 arc::SetArcPlayStoreEnabledForProfile(profile_, true); | |
| 105 // Check initial conditions. | 105 // Check initial conditions. |
| 106 EXPECT_FALSE(arc_session_manager_->IsSessionRunning()); | 106 if (arc::ShouldArcAlwaysStart()) { |
| 107 // When ARC first starts, it runs in opt-out mode of Play Store. |
| 108 EXPECT_TRUE(arc_session_manager_->IsSessionRunning()); |
| 109 } else { |
| 110 arc::SetArcPlayStoreEnabledForProfile(profile_, true); |
| 111 EXPECT_FALSE(arc_session_manager_->IsSessionRunning()); |
| 112 } |
| 107 | 113 |
| 108 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); | 114 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); |
| 109 arc_service_manager_->arc_bridge_service()->app()->SetInstance( | 115 arc_service_manager_->arc_bridge_service()->app()->SetInstance( |
| 110 app_instance_.get()); | 116 app_instance_.get()); |
| 111 } | 117 } |
| 112 | 118 |
| 113 void ArcAppTest::CreateFakeAppsAndPackages() { | 119 void ArcAppTest::CreateFakeAppsAndPackages() { |
| 114 arc::mojom::AppInfo app; | 120 arc::mojom::AppInfo app; |
| 115 // Make sure we have enough data for test. | 121 // Make sure we have enough data for test. |
| 116 for (int i = 0; i < 3; ++i) { | 122 for (int i = 0; i < 3; ++i) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 225 } |
| 220 } | 226 } |
| 221 | 227 |
| 222 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { | 228 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { |
| 223 for (auto fake_package : fake_packages_) { | 229 for (auto fake_package : fake_packages_) { |
| 224 if (package.package_name == fake_package.package_name) | 230 if (package.package_name == fake_package.package_name) |
| 225 return true; | 231 return true; |
| 226 } | 232 } |
| 227 return false; | 233 return false; |
| 228 } | 234 } |
| OLD | NEW |