Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_test.cc

Issue 2248353002: [M53 cherry-pick] Migrate ArcUserDataService into ArcAuthService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_test.h ('k') | components/arc/arc_service_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 9 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
10 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 10 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 12 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" 13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h"
14 #include "chromeos/chromeos_switches.h" 14 #include "chromeos/chromeos_switches.h"
15 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "components/arc/arc_bridge_service.h" 16 #include "components/arc/arc_bridge_service.h"
16 #include "components/arc/test/fake_app_instance.h" 17 #include "components/arc/test/fake_app_instance.h"
17 #include "components/arc/test/fake_arc_bridge_service.h" 18 #include "components/arc/test/fake_arc_bridge_service.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 namespace { 21 namespace {
21 22
22 constexpr char kPackageName1[] = "fakepackagename1"; 23 constexpr char kPackageName1[] = "fakepackagename1";
23 constexpr char kPackageName2[] = "fakepackagename2"; 24 constexpr char kPackageName2[] = "fakepackagename2";
24 constexpr char kPackageName3[] = "fakepackagename3"; 25 constexpr char kPackageName3[] = "fakepackagename3";
(...skipping 15 matching lines...) Expand all
40 41
41 ArcAppTest::~ArcAppTest() { 42 ArcAppTest::~ArcAppTest() {
42 } 43 }
43 44
44 chromeos::FakeChromeUserManager* ArcAppTest::GetUserManager() { 45 chromeos::FakeChromeUserManager* ArcAppTest::GetUserManager() {
45 return static_cast<chromeos::FakeChromeUserManager*>( 46 return static_cast<chromeos::FakeChromeUserManager*>(
46 user_manager::UserManager::Get()); 47 user_manager::UserManager::Get());
47 } 48 }
48 49
49 void ArcAppTest::SetUp(Profile* profile) { 50 void ArcAppTest::SetUp(Profile* profile) {
51 if (!chromeos::DBusThreadManager::IsInitialized()) {
52 chromeos::DBusThreadManager::Initialize();
53 dbus_thread_manager_initialized_ = true;
54 }
50 base::CommandLine::ForCurrentProcess()->AppendSwitch( 55 base::CommandLine::ForCurrentProcess()->AppendSwitch(
51 chromeos::switches::kEnableArc); 56 chromeos::switches::kEnableArc);
52 DCHECK(!profile_); 57 DCHECK(!profile_);
53 profile_ = profile; 58 profile_ = profile;
54 CreateUserAndLogin(); 59 CreateUserAndLogin();
55 60
56 // Make sure we have enough data for test. 61 // Make sure we have enough data for test.
57 for (int i = 0; i < 3; ++i) { 62 for (int i = 0; i < 3; ++i) {
58 arc::mojom::AppInfo app; 63 arc::mojom::AppInfo app;
59 app.name = base::StringPrintf("Fake App %d", i); 64 app.name = base::StringPrintf("Fake App %d", i);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 121
117 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); 122 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_);
118 DCHECK(arc_app_list_pref_); 123 DCHECK(arc_app_list_pref_);
119 124
120 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); 125 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
121 bridge_service_->app()->SetInstance(app_instance_.get()); 126 bridge_service_->app()->SetInstance(app_instance_.get());
122 } 127 }
123 128
124 void ArcAppTest::TearDown() { 129 void ArcAppTest::TearDown() {
125 auth_service_.reset(); 130 auth_service_.reset();
131 if (dbus_thread_manager_initialized_) {
132 // DBusThreadManager may be initialized from other testing utility,
133 // such as ash::test::AshTestHelper::SetUp(), so Shutdown() only when
134 // it is initialized in ArcAppTest::SetUp().
135 chromeos::DBusThreadManager::Shutdown();
136 dbus_thread_manager_initialized_ = false;
137 }
126 } 138 }
127 139
128 void ArcAppTest::StopArcInstance() { 140 void ArcAppTest::StopArcInstance() {
129 bridge_service_->app()->CloseChannel(); 141 bridge_service_->app()->CloseChannel();
130 } 142 }
131 143
132 void ArcAppTest::RestartArcInstance() { 144 void ArcAppTest::RestartArcInstance() {
133 bridge_service_->app()->CloseChannel(); 145 bridge_service_->app()->CloseChannel();
134 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); 146 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
135 bridge_service_->app()->SetInstance(app_instance_.get()); 147 bridge_service_->app()->SetInstance(app_instance_.get());
(...skipping 21 matching lines...) Expand all
157 } 169 }
158 } 170 }
159 171
160 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { 172 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) {
161 for (auto fake_package : fake_packages_) { 173 for (auto fake_package : fake_packages_) {
162 if (package.package_name == fake_package.package_name) 174 if (package.package_name == fake_package.package_name)
163 return true; 175 return true;
164 } 176 }
165 return false; 177 return false;
166 } 178 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_test.h ('k') | components/arc/arc_service_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698