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

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

Issue 2209173002: Migrate ArcUserDataService into ArcAuthService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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/chromeos/profiles/profile_helper.h" 11 #include "chrome/browser/chromeos/profiles/profile_helper.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.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[] = "fake.package.name1"; 23 constexpr char kPackageName1[] = "fake.package.name1";
23 constexpr char kPackageName2[] = "fake.package.name2"; 24 constexpr char kPackageName2[] = "fake.package.name2";
24 constexpr char kPackageName3[] = "fake.package.name3"; 25 constexpr char kPackageName3[] = "fake.package.name3";
(...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 const user_manager::User* user = CreateUserAndLogin(); 59 const user_manager::User* user = CreateUserAndLogin();
55 60
56 // If for any reason the garbage collector kicks in while we are waiting for 61 // If for any reason the garbage collector kicks in while we are waiting for
57 // an icon, have the user-to-profile mapping ready to avoid using the real 62 // an icon, have the user-to-profile mapping ready to avoid using the real
58 // profile manager (which is null). 63 // profile manager (which is null).
59 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, 64 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(user,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); 124 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
120 bridge_service_->app()->SetInstance(app_instance_.get()); 125 bridge_service_->app()->SetInstance(app_instance_.get());
121 126
122 // Check initial conditions. 127 // Check initial conditions.
123 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get()); 128 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get());
124 EXPECT_FALSE(arc::ArcBridgeService::Get()->ready()); 129 EXPECT_FALSE(arc::ArcBridgeService::Get()->ready());
125 } 130 }
126 131
127 void ArcAppTest::TearDown() { 132 void ArcAppTest::TearDown() {
128 auth_service_.reset(); 133 auth_service_.reset();
134 if (dbus_thread_manager_initialized_) {
135 // DBusThreadManager may be initialized from other testing utility,
136 // such as ash::test::AshTestHelper::SetUp(), so Shutdown() only when
137 // it is initialized in ArcAppTest::SetUp().
138 chromeos::DBusThreadManager::Shutdown();
139 dbus_thread_manager_initialized_ = false;
140 }
129 } 141 }
130 142
131 void ArcAppTest::StopArcInstance() { 143 void ArcAppTest::StopArcInstance() {
132 bridge_service_->app()->SetInstance(nullptr); 144 bridge_service_->app()->SetInstance(nullptr);
133 } 145 }
134 146
135 void ArcAppTest::RestartArcInstance() { 147 void ArcAppTest::RestartArcInstance() {
136 bridge_service_->app()->SetInstance(nullptr); 148 bridge_service_->app()->SetInstance(nullptr);
137 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); 149 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
138 bridge_service_->app()->SetInstance(app_instance_.get()); 150 bridge_service_->app()->SetInstance(app_instance_.get());
(...skipping 22 matching lines...) Expand all
161 } 173 }
162 } 174 }
163 175
164 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { 176 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) {
165 for (auto fake_package : fake_packages_) { 177 for (auto fake_package : fake_packages_) {
166 if (package.package_name == fake_package.package_name) 178 if (package.package_name == fake_package.package_name)
167 return true; 179 return true;
168 } 180 }
169 return false; 181 return false;
170 } 182 }
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