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

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

Issue 2255673004: Revert of [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"
16 #include "components/arc/arc_bridge_service.h" 15 #include "components/arc/arc_bridge_service.h"
17 #include "components/arc/test/fake_app_instance.h" 16 #include "components/arc/test/fake_app_instance.h"
18 #include "components/arc/test/fake_arc_bridge_service.h" 17 #include "components/arc/test/fake_arc_bridge_service.h"
19 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
20 19
21 namespace { 20 namespace {
22 21
23 constexpr char kPackageName1[] = "fakepackagename1"; 22 constexpr char kPackageName1[] = "fakepackagename1";
24 constexpr char kPackageName2[] = "fakepackagename2"; 23 constexpr char kPackageName2[] = "fakepackagename2";
25 constexpr char kPackageName3[] = "fakepackagename3"; 24 constexpr char kPackageName3[] = "fakepackagename3";
(...skipping 15 matching lines...) Expand all
41 40
42 ArcAppTest::~ArcAppTest() { 41 ArcAppTest::~ArcAppTest() {
43 } 42 }
44 43
45 chromeos::FakeChromeUserManager* ArcAppTest::GetUserManager() { 44 chromeos::FakeChromeUserManager* ArcAppTest::GetUserManager() {
46 return static_cast<chromeos::FakeChromeUserManager*>( 45 return static_cast<chromeos::FakeChromeUserManager*>(
47 user_manager::UserManager::Get()); 46 user_manager::UserManager::Get());
48 } 47 }
49 48
50 void ArcAppTest::SetUp(Profile* profile) { 49 void ArcAppTest::SetUp(Profile* profile) {
51 if (!chromeos::DBusThreadManager::IsInitialized()) {
52 chromeos::DBusThreadManager::Initialize();
53 dbus_thread_manager_initialized_ = true;
54 }
55 base::CommandLine::ForCurrentProcess()->AppendSwitch( 50 base::CommandLine::ForCurrentProcess()->AppendSwitch(
56 chromeos::switches::kEnableArc); 51 chromeos::switches::kEnableArc);
57 DCHECK(!profile_); 52 DCHECK(!profile_);
58 profile_ = profile; 53 profile_ = profile;
59 CreateUserAndLogin(); 54 CreateUserAndLogin();
60 55
61 // Make sure we have enough data for test. 56 // Make sure we have enough data for test.
62 for (int i = 0; i < 3; ++i) { 57 for (int i = 0; i < 3; ++i) {
63 arc::mojom::AppInfo app; 58 arc::mojom::AppInfo app;
64 app.name = base::StringPrintf("Fake App %d", i); 59 app.name = base::StringPrintf("Fake App %d", i);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 116
122 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); 117 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_);
123 DCHECK(arc_app_list_pref_); 118 DCHECK(arc_app_list_pref_);
124 119
125 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); 120 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
126 bridge_service_->app()->SetInstance(app_instance_.get()); 121 bridge_service_->app()->SetInstance(app_instance_.get());
127 } 122 }
128 123
129 void ArcAppTest::TearDown() { 124 void ArcAppTest::TearDown() {
130 auth_service_.reset(); 125 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 }
138 } 126 }
139 127
140 void ArcAppTest::StopArcInstance() { 128 void ArcAppTest::StopArcInstance() {
141 bridge_service_->app()->CloseChannel(); 129 bridge_service_->app()->CloseChannel();
142 } 130 }
143 131
144 void ArcAppTest::RestartArcInstance() { 132 void ArcAppTest::RestartArcInstance() {
145 bridge_service_->app()->CloseChannel(); 133 bridge_service_->app()->CloseChannel();
146 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); 134 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
147 bridge_service_->app()->SetInstance(app_instance_.get()); 135 bridge_service_->app()->SetInstance(app_instance_.get());
(...skipping 21 matching lines...) Expand all
169 } 157 }
170 } 158 }
171 159
172 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { 160 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) {
173 for (auto fake_package : fake_packages_) { 161 for (auto fake_package : fake_packages_) {
174 if (package.package_name == fake_package.package_name) 162 if (package.package_name == fake_package.package_name)
175 return true; 163 return true;
176 } 164 }
177 return false; 165 return false;
178 } 166 }
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