Chromium Code Reviews| 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/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" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 auth_service_->EnableArc(); | 114 auth_service_->EnableArc(); |
| 115 | 115 |
| 116 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | 116 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); |
| 117 DCHECK(arc_app_list_pref_); | 117 DCHECK(arc_app_list_pref_); |
| 118 | 118 |
| 119 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); | 119 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); |
| 120 bridge_service_->app()->SetInstance(app_instance_.get()); | 120 bridge_service_->app()->SetInstance(app_instance_.get()); |
| 121 | 121 |
| 122 // Check initial conditions. | 122 // Check initial conditions. |
| 123 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get()); | 123 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get()); |
| 124 EXPECT_TRUE(!arc::ArcBridgeService::Get()->available()); | 124 EXPECT_FALSE(arc::ArcBridgeService::Get()->available()); |
| 125 EXPECT_FALSE(arc::ArcBridgeService::Get()->ready()); | 125 EXPECT_FALSE(arc::ArcBridgeService::Get()->ready()); |
| 126 | 126 |
| 127 // At this point we should have ArcAppListPrefs as observer of service. | 127 SetBridgeServiceReady(); |
| 128 EXPECT_TRUE(bridge_service_->HasObserver(arc_app_list_pref_)); | |
| 129 bridge_service()->SetReady(); | |
| 130 } | 128 } |
| 131 | 129 |
| 132 void ArcAppTest::TearDown() { | 130 void ArcAppTest::TearDown() { |
| 133 auth_service_.reset(); | 131 auth_service_.reset(); |
| 134 } | 132 } |
| 135 | 133 |
| 134 void ArcAppTest::SetBridgeServiceReady() { | |
| 135 bridge_service_->SetReady(); | |
|
Luis Héctor Chávez
2016/07/25 17:31:17
Discussed offline, please try to not touch the bri
lgcheng
2016/07/25 20:45:17
Touch to bridge_service removed.
| |
| 136 } | |
| 137 | |
| 138 void ArcAppTest::SetBridgeServiceStopped() { | |
| 139 bridge_service_->app()->CloseChannel(); | |
| 140 bridge_service_->SetStopped(); | |
| 141 } | |
| 142 | |
| 143 void ArcAppTest::ResetBridgeServiceReady() { | |
| 144 ResetAppInstance(); | |
| 145 bridge_service_->SetReady(); | |
| 146 } | |
| 147 | |
| 148 void ArcAppTest::ResetAppInstance() { | |
| 149 bridge_service_->app()->CloseChannel(); | |
| 150 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); | |
| 151 bridge_service_->app()->SetInstance(app_instance_.get()); | |
| 152 } | |
| 153 | |
| 136 const user_manager::User* ArcAppTest::CreateUserAndLogin() { | 154 const user_manager::User* ArcAppTest::CreateUserAndLogin() { |
| 137 const AccountId account_id(AccountId::FromUserEmailGaiaId( | 155 const AccountId account_id(AccountId::FromUserEmailGaiaId( |
| 138 profile_->GetProfileUserName(), "1234567890")); | 156 profile_->GetProfileUserName(), "1234567890")); |
| 139 const user_manager::User* user = GetUserManager()->AddUser(account_id); | 157 const user_manager::User* user = GetUserManager()->AddUser(account_id); |
| 140 GetUserManager()->LoginUser(account_id); | 158 GetUserManager()->LoginUser(account_id); |
| 141 return user; | 159 return user; |
| 142 } | 160 } |
| 143 | 161 |
| 144 void ArcAppTest::AddPackage(const arc::mojom::ArcPackageInfo& package) { | 162 void ArcAppTest::AddPackage(const arc::mojom::ArcPackageInfo& package) { |
| 145 if (!FindPackage(package)) | 163 if (!FindPackage(package)) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 156 } | 174 } |
| 157 } | 175 } |
| 158 | 176 |
| 159 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { | 177 bool ArcAppTest::FindPackage(const arc::mojom::ArcPackageInfo& package) { |
| 160 for (auto fake_package : fake_packages_) { | 178 for (auto fake_package : fake_packages_) { |
| 161 if (package.package_name == fake_package.package_name) | 179 if (package.package_name == fake_package.package_name) |
| 162 return true; | 180 return true; |
| 163 } | 181 } |
| 164 return false; | 182 return false; |
| 165 } | 183 } |
| OLD | NEW |