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

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

Issue 2596273002: Move ArcSessionRunner from ArcBridgeService to ArcSessionManager. (Closed)
Patch Set: Rebase and update comments. Created 3 years, 12 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
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/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"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, 72 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(user,
73 profile_); 73 profile_);
74 74
75 // A valid |arc_app_list_prefs_| is needed for the Arc bridge service and the 75 // A valid |arc_app_list_prefs_| is needed for the Arc bridge service and the
76 // Arc auth service. 76 // Arc auth service.
77 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); 77 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_);
78 if (!arc_app_list_pref_) { 78 if (!arc_app_list_pref_) {
79 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting( 79 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting(
80 profile_); 80 profile_);
81 } 81 }
82 arc::ArcServiceManager::SetArcSessionRunnerForTesting( 82 arc_service_manager_ = base::MakeUnique<arc::ArcServiceManager>(nullptr);
83 arc_session_manager_ = base::MakeUnique<arc::ArcSessionManager>(
83 base::MakeUnique<arc::ArcSessionRunner>( 84 base::MakeUnique<arc::ArcSessionRunner>(
84 base::Bind(arc::FakeArcSession::Create))); 85 base::Bind(arc::FakeArcSession::Create)));
85 arc_service_manager_ = base::MakeUnique<arc::ArcServiceManager>(nullptr);
86 arc_session_manager_ = base::MakeUnique<arc::ArcSessionManager>(
87 arc_service_manager_->arc_bridge_service());
88 DCHECK(arc::ArcSessionManager::Get()); 86 DCHECK(arc::ArcSessionManager::Get());
89 arc::ArcSessionManager::DisableUIForTesting(); 87 arc::ArcSessionManager::DisableUIForTesting();
90 arc_session_manager_->OnPrimaryUserProfilePrepared(profile_); 88 arc_session_manager_->OnPrimaryUserProfilePrepared(profile_);
91 89
92 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); 90 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_);
93 DCHECK(arc_app_list_pref_); 91 DCHECK(arc_app_list_pref_);
94 base::RunLoop run_loop; 92 base::RunLoop run_loop;
95 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); 93 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure());
96 run_loop.Run(); 94 run_loop.Run();
97 95
98 arc_session_manager_->EnableArc(); 96 arc_session_manager_->EnableArc();
97 // Check initial conditions.
98 EXPECT_FALSE(arc_session_manager_->IsSessionRunning());
99
99 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); 100 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_));
100 arc_service_manager_->arc_bridge_service()->app()->SetInstance( 101 arc_service_manager_->arc_bridge_service()->app()->SetInstance(
101 app_instance_.get()); 102 app_instance_.get());
102
103 // Check initial conditions.
104 EXPECT_FALSE(arc_service_manager_->arc_bridge_service()->ready());
105 } 103 }
106 104
107 void ArcAppTest::CreateFakeAppsAndPackages() { 105 void ArcAppTest::CreateFakeAppsAndPackages() {
108 arc::mojom::AppInfo app; 106 arc::mojom::AppInfo app;
109 // Make sure we have enough data for test. 107 // Make sure we have enough data for test.
110 for (int i = 0; i < 3; ++i) { 108 for (int i = 0; i < 3; ++i) {
111 app.name = base::StringPrintf("Fake App %d", i); 109 app.name = base::StringPrintf("Fake App %d", i);
112 app.package_name = base::StringPrintf("fake.app.%d", i); 110 app.package_name = base::StringPrintf("fake.app.%d", i);
113 app.activity = base::StringPrintf("fake.app.%d.activity", i); 111 app.activity = base::StringPrintf("fake.app.%d.activity", i);
114 app.sticky = false; 112 app.sticky = false;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 210 }
213 } 211 }
214 212
215 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { 213 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) {
216 for (auto fake_package : fake_packages_) { 214 for (auto fake_package : fake_packages_) {
217 if (package.package_name == fake_package.package_name) 215 if (package.package_name == fake_package.package_name)
218 return true; 216 return true;
219 } 217 }
220 return false; 218 return false;
221 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698