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_session_manager.h" | 11 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
12 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 12 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
13 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 13 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
14 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 14 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 16 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
17 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | 17 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" |
18 #include "chromeos/chromeos_switches.h" | |
18 #include "chromeos/dbus/dbus_thread_manager.h" | 19 #include "chromeos/dbus/dbus_thread_manager.h" |
19 #include "components/arc/arc_bridge_service.h" | 20 #include "components/arc/arc_bridge_service.h" |
20 #include "components/arc/arc_service_manager.h" | 21 #include "components/arc/arc_service_manager.h" |
21 #include "components/arc/arc_session_runner.h" | 22 #include "components/arc/arc_session_runner.h" |
22 #include "components/arc/arc_util.h" | 23 #include "components/arc/arc_util.h" |
23 #include "components/arc/test/fake_app_instance.h" | 24 #include "components/arc/test/fake_app_instance.h" |
24 #include "components/arc/test/fake_arc_session.h" | 25 #include "components/arc/test/fake_arc_session.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 constexpr char kPackageName1[] = "fake.package.name1"; | 30 constexpr char kPackageName1[] = "fake.package.name1"; |
30 constexpr char kPackageName2[] = "fake.package.name2"; | 31 constexpr char kPackageName2[] = "fake.package.name2"; |
31 constexpr char kPackageName3[] = "fake.package.name3"; | 32 constexpr char kPackageName3[] = "fake.package.name3"; |
32 } | 33 } |
33 | 34 |
34 // static | 35 // static |
36 void ArcAppTest::Init(bool is_persistent_arc) { | |
hidehiko
2017/02/23 10:29:16
Could you move this to components/arc/arc_util, to
victorhsieh
2017/02/24 00:45:00
Done.
| |
37 if (is_persistent_arc) { | |
38 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
39 chromeos::switches::kEnableArcPersistently); | |
40 } | |
41 } | |
42 | |
43 // static | |
35 std::string ArcAppTest::GetAppId(const arc::mojom::AppInfo& app_info) { | 44 std::string ArcAppTest::GetAppId(const arc::mojom::AppInfo& app_info) { |
36 return ArcAppListPrefs::GetAppId(app_info.package_name, app_info.activity); | 45 return ArcAppListPrefs::GetAppId(app_info.package_name, app_info.activity); |
37 } | 46 } |
38 | 47 |
39 // static | 48 // static |
40 std::string ArcAppTest::GetAppId(const arc::mojom::ShortcutInfo& shortcut) { | 49 std::string ArcAppTest::GetAppId(const arc::mojom::ShortcutInfo& shortcut) { |
41 return ArcAppListPrefs::GetAppId(shortcut.package_name, shortcut.intent_uri); | 50 return ArcAppListPrefs::GetAppId(shortcut.package_name, shortcut.intent_uri); |
42 } | 51 } |
43 | 52 |
44 ArcAppTest::ArcAppTest() { | 53 ArcAppTest::ArcAppTest() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 DCHECK(arc::ArcSessionManager::Get()); | 95 DCHECK(arc::ArcSessionManager::Get()); |
87 arc::ArcSessionManager::DisableUIForTesting(); | 96 arc::ArcSessionManager::DisableUIForTesting(); |
88 arc_session_manager_->OnPrimaryUserProfilePrepared(profile_); | 97 arc_session_manager_->OnPrimaryUserProfilePrepared(profile_); |
89 | 98 |
90 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | 99 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); |
91 DCHECK(arc_app_list_pref_); | 100 DCHECK(arc_app_list_pref_); |
92 base::RunLoop run_loop; | 101 base::RunLoop run_loop; |
93 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); | 102 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
94 run_loop.Run(); | 103 run_loop.Run(); |
95 | 104 |
96 arc_session_manager_->SetArcPlayStoreEnabled(true); | |
97 // Check initial conditions. | 105 // Check initial conditions. |
98 EXPECT_FALSE(arc_session_manager_->IsSessionRunning()); | 106 if (arc_session_manager_->IsPersistentArc()) { |
107 // On Persistent ARC, Play Store is opted out by default. | |
108 EXPECT_TRUE(arc_session_manager_->IsSessionRunning()); | |
109 } else { | |
110 arc_session_manager_->SetArcPlayStoreEnabled(true); | |
111 EXPECT_FALSE(arc_session_manager_->IsSessionRunning()); | |
112 } | |
99 | 113 |
100 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); | 114 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); |
101 arc_service_manager_->arc_bridge_service()->app()->SetInstance( | 115 arc_service_manager_->arc_bridge_service()->app()->SetInstance( |
102 app_instance_.get()); | 116 app_instance_.get()); |
103 } | 117 } |
104 | 118 |
105 void ArcAppTest::CreateFakeAppsAndPackages() { | 119 void ArcAppTest::CreateFakeAppsAndPackages() { |
106 arc::mojom::AppInfo app; | 120 arc::mojom::AppInfo app; |
107 // Make sure we have enough data for test. | 121 // Make sure we have enough data for test. |
108 for (int i = 0; i < 3; ++i) { | 122 for (int i = 0; i < 3; ++i) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 } | 224 } |
211 } | 225 } |
212 | 226 |
213 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { | 227 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { |
214 for (auto fake_package : fake_packages_) { | 228 for (auto fake_package : fake_packages_) { |
215 if (package.package_name == fake_package.package_name) | 229 if (package.package_name == fake_package.package_name) |
216 return true; | 230 return true; |
217 } | 231 } |
218 return false; | 232 return false; |
219 } | 233 } |
OLD | NEW |