OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/app_mode/kiosk_app_manager.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" |
9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 12 #include "base/path_service.h" |
11 #include "base/prefs/scoped_user_pref_update.h" | 13 #include "base/prefs/scoped_user_pref_update.h" |
12 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" | 17 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" |
16 #include "chrome/browser/chromeos/policy/device_local_account.h" | 18 #include "chrome/browser/chromeos/policy/device_local_account.h" |
17 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
18 #include "chrome/browser/policy/browser_policy_connector.h" | 20 #include "chrome/browser/policy/browser_policy_connector.h" |
| 21 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/extensions/extension.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chromeos/settings/cros_settings_names.h" | 26 #include "chromeos/settings/cros_settings_names.h" |
23 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
24 #include "net/base/host_port_pair.h" | 28 #include "net/base/host_port_pair.h" |
25 #include "net/dns/mock_host_resolver.h" | 29 #include "net/dns/mock_host_resolver.h" |
| 30 #include "net/test/embedded_test_server/embedded_test_server.h" |
26 | 31 |
27 namespace chromeos { | 32 namespace chromeos { |
28 | 33 |
29 namespace { | 34 namespace { |
30 | 35 |
31 const char kWebstoreDomain[] = "cws.com"; | 36 const char kWebstoreDomain[] = "cws.com"; |
32 | 37 |
33 // Helper KioskAppManager::GetConsumerKioskModeStatusCallback implementation. | 38 // Helper KioskAppManager::GetConsumerKioskModeStatusCallback implementation. |
34 void ConsumerKioskModeStatusCheck( | 39 void ConsumerKioskModeStatusCheck( |
35 KioskAppManager::ConsumerKioskModeStatus* out_status, | 40 KioskAppManager::ConsumerKioskModeStatus* out_status, |
(...skipping 17 matching lines...) Expand all Loading... |
53 // Helper EnterpriseInstallAttributes::LockResultCallback implementation. | 58 // Helper EnterpriseInstallAttributes::LockResultCallback implementation. |
54 void OnEnterpriseDeviceLock( | 59 void OnEnterpriseDeviceLock( |
55 policy::EnterpriseInstallAttributes::LockResult* out_locked, | 60 policy::EnterpriseInstallAttributes::LockResult* out_locked, |
56 const base::Closure& runner_quit_task, | 61 const base::Closure& runner_quit_task, |
57 policy::EnterpriseInstallAttributes::LockResult in_locked) { | 62 policy::EnterpriseInstallAttributes::LockResult in_locked) { |
58 LOG(INFO) << "Enterprise lock = " << in_locked; | 63 LOG(INFO) << "Enterprise lock = " << in_locked; |
59 *out_locked = in_locked; | 64 *out_locked = in_locked; |
60 runner_quit_task.Run(); | 65 runner_quit_task.Run(); |
61 } | 66 } |
62 | 67 |
| 68 scoped_refptr<extensions::Extension> MakeApp(const std::string& name, |
| 69 const std::string& version, |
| 70 const std::string& url, |
| 71 const std::string& id) { |
| 72 std::string err; |
| 73 base::DictionaryValue value; |
| 74 value.SetString("name", name); |
| 75 value.SetString("version", version); |
| 76 value.SetString("app.launch.web_url", url); |
| 77 scoped_refptr<extensions::Extension> app = |
| 78 extensions::Extension::Create( |
| 79 base::FilePath(), |
| 80 extensions::Manifest::INTERNAL, |
| 81 value, |
| 82 extensions::Extension::WAS_INSTALLED_BY_DEFAULT, |
| 83 id, |
| 84 &err); |
| 85 EXPECT_EQ(err, ""); |
| 86 return app; |
| 87 } |
| 88 |
63 class TestKioskAppManagerObserver : public KioskAppManagerObserver { | 89 class TestKioskAppManagerObserver : public KioskAppManagerObserver { |
64 public: | 90 public: |
65 explicit TestKioskAppManagerObserver(KioskAppManager* manager) | 91 explicit TestKioskAppManagerObserver(KioskAppManager* manager) |
66 : manager_(manager), | 92 : manager_(manager), |
67 data_changed_count_(0), | 93 data_changed_count_(0), |
68 load_failure_count_(0) { | 94 load_failure_count_(0) { |
69 manager_->AddObserver(this); | 95 manager_->AddObserver(this); |
70 } | 96 } |
71 virtual ~TestKioskAppManagerObserver() { | 97 virtual ~TestKioskAppManagerObserver() { |
72 manager_->RemoveObserver(this); | 98 manager_->RemoveObserver(this); |
(...skipping 21 matching lines...) Expand all Loading... |
94 int load_failure_count_; | 120 int load_failure_count_; |
95 | 121 |
96 DISALLOW_COPY_AND_ASSIGN(TestKioskAppManagerObserver); | 122 DISALLOW_COPY_AND_ASSIGN(TestKioskAppManagerObserver); |
97 }; | 123 }; |
98 | 124 |
99 class AppDataLoadWaiter : public KioskAppManagerObserver { | 125 class AppDataLoadWaiter : public KioskAppManagerObserver { |
100 public: | 126 public: |
101 explicit AppDataLoadWaiter(KioskAppManager* manager) | 127 explicit AppDataLoadWaiter(KioskAppManager* manager) |
102 : manager_(manager), | 128 : manager_(manager), |
103 loaded_(false) { | 129 loaded_(false) { |
104 manager_->AddObserver(this); | |
105 } | 130 } |
106 virtual ~AppDataLoadWaiter() { | 131 virtual ~AppDataLoadWaiter() { |
| 132 } |
| 133 |
| 134 void Wait() { |
| 135 manager_->AddObserver(this); |
| 136 runner_ = new content::MessageLoopRunner; |
| 137 runner_->Run(); |
107 manager_->RemoveObserver(this); | 138 manager_->RemoveObserver(this); |
108 } | 139 } |
109 | 140 |
110 void Wait() { | |
111 base::MessageLoop::current()->Run(); | |
112 } | |
113 | |
114 bool loaded() const { return loaded_; } | 141 bool loaded() const { return loaded_; } |
115 | 142 |
116 private: | 143 private: |
117 // KioskAppManagerObserver overrides: | 144 // KioskAppManagerObserver overrides: |
118 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE { | 145 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE { |
119 loaded_ = true; | 146 loaded_ = true; |
120 base::MessageLoop::current()->Quit(); | 147 base::MessageLoop::current()->Quit(); |
121 } | 148 } |
122 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE { | 149 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE { |
123 loaded_ = false; | 150 loaded_ = false; |
124 base::MessageLoop::current()->Quit(); | 151 base::MessageLoop::current()->Quit(); |
125 } | 152 } |
126 | 153 |
| 154 scoped_refptr<content::MessageLoopRunner> runner_; |
127 KioskAppManager* manager_; | 155 KioskAppManager* manager_; |
128 bool loaded_; | 156 bool loaded_; |
129 | 157 |
130 DISALLOW_COPY_AND_ASSIGN(AppDataLoadWaiter); | 158 DISALLOW_COPY_AND_ASSIGN(AppDataLoadWaiter); |
131 }; | 159 }; |
132 | 160 |
133 } // namespace | 161 } // namespace |
134 | 162 |
135 class KioskAppManagerTest : public InProcessBrowserTest { | 163 class KioskAppManagerTest : public InProcessBrowserTest { |
136 public: | 164 public: |
137 KioskAppManagerTest() {} | 165 KioskAppManagerTest() {} |
138 virtual ~KioskAppManagerTest() {} | 166 virtual ~KioskAppManagerTest() {} |
139 | 167 |
140 // InProcessBrowserTest overrides: | 168 // InProcessBrowserTest overrides: |
| 169 virtual void SetUp() OVERRIDE { |
| 170 base::FilePath test_data_dir; |
| 171 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
| 172 base::FilePath webstore_dir = |
| 173 test_data_dir.Append(FILE_PATH_LITERAL("chromeos/app_mode/")); |
| 174 embedded_test_server()->ServeFilesFromDirectory(webstore_dir); |
| 175 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 176 // Stop IO thread here because no threads are allowed while |
| 177 // spawning sandbox host process. See crbug.com/322732. |
| 178 // embedded_test_server()->StopThread(); |
| 179 |
| 180 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 181 |
| 182 InProcessBrowserTest::SetUp(); |
| 183 } |
| 184 |
141 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 185 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
142 // We start the test server now instead of in | 186 InProcessBrowserTest::SetUpCommandLine(command_line); |
143 // SetUpInProcessBrowserTestFixture so that we can get its port number. | |
144 ASSERT_TRUE(test_server()->Start()); | |
145 | 187 |
146 net::HostPortPair host_port = test_server()->host_port_pair(); | 188 // Get fake webstore gallery URL. At the end, it should look something like |
147 test_gallery_url_ = base::StringPrintf( | 189 // http://cws.com:<test_server_port>/webstore. |
148 "http://%s:%d/files/chromeos/app_mode/webstore", | 190 const GURL& server_url = embedded_test_server()->base_url(); |
149 kWebstoreDomain, host_port.port()); | 191 std::string google_host(kWebstoreDomain); |
| 192 GURL::Replacements replace_google_host; |
| 193 replace_google_host.SetHostStr(google_host); |
| 194 GURL google_url = server_url.ReplaceComponents(replace_google_host); |
| 195 GURL fake_store_url = google_url.Resolve("/webstore"); |
| 196 command_line->AppendSwitchASCII(switches::kAppsGalleryURL, |
| 197 fake_store_url.spec()); |
| 198 } |
150 | 199 |
151 command_line->AppendSwitchASCII( | 200 virtual void SetUpOnMainThread() OVERRIDE { |
152 switches::kAppsGalleryURL, test_gallery_url_); | 201 InProcessBrowserTest::SetUpOnMainThread(); |
| 202 |
| 203 // Restart the thread as the sandbox host process has already been spawned. |
| 204 // embedded_test_server()->RestartThreadAndListen(); |
153 } | 205 } |
| 206 |
154 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 207 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 208 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 209 |
155 host_resolver()->AddRule(kWebstoreDomain, "127.0.0.1"); | 210 host_resolver()->AddRule(kWebstoreDomain, "127.0.0.1"); |
156 } | 211 } |
157 | 212 |
158 std::string GetAppIds() const { | 213 std::string GetAppIds() const { |
159 KioskAppManager::Apps apps; | 214 KioskAppManager::Apps apps; |
160 manager()->GetApps(&apps); | 215 manager()->GetApps(&apps); |
161 | 216 |
162 std::string str; | 217 std::string str; |
163 for (size_t i = 0; i < apps.size(); ++i) { | 218 for (size_t i = 0; i < apps.size(); ++i) { |
164 if (i > 0) | 219 if (i > 0) |
165 str += ','; | 220 str += ','; |
166 str += apps[i].app_id; | 221 str += apps[i].app_id; |
167 } | 222 } |
168 | 223 |
169 return str; | 224 return str; |
170 } | 225 } |
171 | 226 |
172 KioskAppManager* manager() const { return KioskAppManager::Get(); } | |
173 | |
174 // Locks device for enterprise. | 227 // Locks device for enterprise. |
175 policy::EnterpriseInstallAttributes::LockResult LockDeviceForEnterprise() { | 228 policy::EnterpriseInstallAttributes::LockResult LockDeviceForEnterprise() { |
176 scoped_ptr<policy::EnterpriseInstallAttributes::LockResult> lock_result( | 229 scoped_ptr<policy::EnterpriseInstallAttributes::LockResult> lock_result( |
177 new policy::EnterpriseInstallAttributes::LockResult( | 230 new policy::EnterpriseInstallAttributes::LockResult( |
178 policy::EnterpriseInstallAttributes::LOCK_NOT_READY)); | 231 policy::EnterpriseInstallAttributes::LOCK_NOT_READY)); |
179 scoped_refptr<content::MessageLoopRunner> runner = | 232 scoped_refptr<content::MessageLoopRunner> runner = |
180 new content::MessageLoopRunner; | 233 new content::MessageLoopRunner; |
181 g_browser_process->browser_policy_connector()->GetInstallAttributes()-> | 234 g_browser_process->browser_policy_connector()->GetInstallAttributes()-> |
182 LockDevice( | 235 LockDevice( |
183 "user@domain.com", | 236 "user@domain.com", |
184 policy::DEVICE_MODE_ENTERPRISE, | 237 policy::DEVICE_MODE_ENTERPRISE, |
185 "device-id", | 238 "device-id", |
186 base::Bind(&OnEnterpriseDeviceLock, | 239 base::Bind(&OnEnterpriseDeviceLock, |
187 lock_result.get(), | 240 lock_result.get(), |
188 runner->QuitClosure())); | 241 runner->QuitClosure())); |
189 runner->Run(); | 242 runner->Run(); |
190 return *lock_result.get(); | 243 return *lock_result.get(); |
191 } | 244 } |
192 | 245 |
| 246 void SetExistingApp(const std::string& app_id, |
| 247 const std::string& app_name, |
| 248 const std::string& icon_file_name) { |
| 249 base::FilePath test_dir; |
| 250 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
| 251 base::FilePath data_dir = test_dir.AppendASCII("chromeos/app_mode/"); |
| 252 |
| 253 // Copy the icon file to temp dir for using because ClearAppData test |
| 254 // deletes it. |
| 255 base::FilePath icon_path = temp_dir_.path().AppendASCII(icon_file_name); |
| 256 base::CopyFile(data_dir.AppendASCII(icon_file_name), icon_path); |
| 257 |
| 258 scoped_ptr<base::DictionaryValue> apps_dict(new base::DictionaryValue); |
| 259 apps_dict->SetString(app_id + ".name", app_name); |
| 260 apps_dict->SetString(app_id + ".icon", icon_path.MaybeAsASCII()); |
| 261 |
| 262 PrefService* local_state = g_browser_process->local_state(); |
| 263 DictionaryPrefUpdate dict_update(local_state, |
| 264 KioskAppManager::kKioskDictionaryName); |
| 265 dict_update->Set(KioskAppManager::kKeyApps, apps_dict.release()); |
| 266 |
| 267 // Make the app appear in device settings. |
| 268 base::ListValue device_local_accounts; |
| 269 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 270 entry->SetStringWithoutPathExpansion( |
| 271 kAccountsPrefDeviceLocalAccountsKeyId, |
| 272 app_id + "_id"); |
| 273 entry->SetIntegerWithoutPathExpansion( |
| 274 kAccountsPrefDeviceLocalAccountsKeyType, |
| 275 policy::DeviceLocalAccount::TYPE_KIOSK_APP); |
| 276 entry->SetStringWithoutPathExpansion( |
| 277 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, |
| 278 app_id); |
| 279 device_local_accounts.Append(entry.release()); |
| 280 CrosSettings::Get()->Set(kAccountsPrefDeviceLocalAccounts, |
| 281 device_local_accounts); |
| 282 } |
| 283 |
| 284 KioskAppManager* manager() const { return KioskAppManager::Get(); } |
| 285 |
193 private: | 286 private: |
194 std::string test_gallery_url_; | 287 base::ScopedTempDir temp_dir_; |
195 base::ShadowingAtExitManager exit_manager_; | |
196 | 288 |
197 DISALLOW_COPY_AND_ASSIGN(KioskAppManagerTest); | 289 DISALLOW_COPY_AND_ASSIGN(KioskAppManagerTest); |
198 }; | 290 }; |
199 | 291 |
200 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, Basic) { | 292 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, Basic) { |
201 // Add a couple of apps. Use "fake_app_x" that do not have data on the test | 293 // Add a couple of apps. Use "fake_app_x" that do not have data on the test |
202 // server to avoid pending data loads that could be lingering on tear down and | 294 // server to avoid pending data loads that could be lingering on tear down and |
203 // cause DCHECK failure in utility_process_host_impl.cc. | 295 // cause DCHECK failure in utility_process_host_impl.cc. |
204 manager()->AddApp("fake_app_1"); | 296 manager()->AddApp("fake_app_1"); |
205 manager()->AddApp("fake_app_2"); | 297 manager()->AddApp("fake_app_2"); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 manager()->SetAutoLaunchApp("none_exist_app"); | 331 manager()->SetAutoLaunchApp("none_exist_app"); |
240 EXPECT_EQ("", manager()->GetAutoLaunchApp()); | 332 EXPECT_EQ("", manager()->GetAutoLaunchApp()); |
241 EXPECT_FALSE(manager()->IsAutoLaunchEnabled()); | 333 EXPECT_FALSE(manager()->IsAutoLaunchEnabled()); |
242 | 334 |
243 // Add an existing app again. | 335 // Add an existing app again. |
244 manager()->AddApp("fake_app_1"); | 336 manager()->AddApp("fake_app_1"); |
245 EXPECT_EQ("fake_app_1", GetAppIds()); | 337 EXPECT_EQ("fake_app_1", GetAppIds()); |
246 } | 338 } |
247 | 339 |
248 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, LoadCached) { | 340 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, LoadCached) { |
249 base::FilePath test_dir; | 341 SetExistingApp("app_1", "Cached App1 Name", "red16x16.png"); |
250 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | |
251 base::FilePath data_dir = test_dir.AppendASCII("chromeos/app_mode/"); | |
252 | |
253 scoped_ptr<base::DictionaryValue> apps_dict(new base::DictionaryValue); | |
254 apps_dict->SetString("app_1.name", "App1 Name"); | |
255 std::string icon_path = | |
256 base::StringPrintf("%s/red16x16.png", data_dir.value().c_str()); | |
257 apps_dict->SetString("app_1.icon", icon_path); | |
258 | |
259 PrefService* local_state = g_browser_process->local_state(); | |
260 DictionaryPrefUpdate dict_update(local_state, | |
261 KioskAppManager::kKioskDictionaryName); | |
262 dict_update->Set(KioskAppManager::kKeyApps, apps_dict.release()); | |
263 | |
264 // Make the app appear in device settings. | |
265 base::ListValue device_local_accounts; | |
266 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | |
267 entry->SetStringWithoutPathExpansion( | |
268 kAccountsPrefDeviceLocalAccountsKeyId, | |
269 "app_1_id"); | |
270 entry->SetIntegerWithoutPathExpansion( | |
271 kAccountsPrefDeviceLocalAccountsKeyType, | |
272 policy::DeviceLocalAccount::TYPE_KIOSK_APP); | |
273 entry->SetStringWithoutPathExpansion( | |
274 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, | |
275 "app_1"); | |
276 device_local_accounts.Append(entry.release()); | |
277 CrosSettings::Get()->Set(kAccountsPrefDeviceLocalAccounts, | |
278 device_local_accounts); | |
279 | 342 |
280 AppDataLoadWaiter waiter(manager()); | 343 AppDataLoadWaiter waiter(manager()); |
281 waiter.Wait(); | 344 waiter.Wait(); |
282 EXPECT_TRUE(waiter.loaded()); | 345 EXPECT_TRUE(waiter.loaded()); |
| 346 |
| 347 KioskAppManager::Apps apps; |
| 348 manager()->GetApps(&apps); |
| 349 EXPECT_EQ(1u, apps.size()); |
| 350 EXPECT_EQ("app_1", apps[0].app_id); |
| 351 EXPECT_EQ("Cached App1 Name", apps[0].name); |
| 352 EXPECT_EQ(gfx::Size(16, 16), apps[0].icon.size()); |
| 353 } |
| 354 |
| 355 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, ClearAppData) { |
| 356 SetExistingApp("app_1", "Cached App1 Name", "red16x16.png"); |
| 357 |
| 358 PrefService* local_state = g_browser_process->local_state(); |
| 359 const base::DictionaryValue* dict = |
| 360 local_state->GetDictionary(KioskAppManager::kKioskDictionaryName); |
| 361 const base::DictionaryValue* apps_dict; |
| 362 EXPECT_TRUE(dict->GetDictionary(KioskAppManager::kKeyApps, &apps_dict)); |
| 363 EXPECT_TRUE(apps_dict->HasKey("app_1")); |
| 364 |
| 365 manager()->ClearAppData("app_1"); |
| 366 |
| 367 EXPECT_FALSE(apps_dict->HasKey("app_1")); |
| 368 } |
| 369 |
| 370 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, UpdateAppDataFromProfile) { |
| 371 SetExistingApp("app_1", "Cached App1 Name", "red16x16.png"); |
| 372 |
| 373 AppDataLoadWaiter waiter(manager()); |
| 374 waiter.Wait(); |
| 375 EXPECT_TRUE(waiter.loaded()); |
283 | 376 |
284 KioskAppManager::Apps apps; | 377 KioskAppManager::Apps apps; |
285 manager()->GetApps(&apps); | 378 manager()->GetApps(&apps); |
286 EXPECT_EQ(1u, apps.size()); | 379 EXPECT_EQ(1u, apps.size()); |
287 EXPECT_EQ("app_1", apps[0].app_id); | 380 EXPECT_EQ("app_1", apps[0].app_id); |
288 EXPECT_EQ("App1 Name", apps[0].name); | 381 EXPECT_EQ("Cached App1 Name", apps[0].name); |
289 EXPECT_EQ(gfx::Size(16, 16), apps[0].icon.size()); | 382 |
| 383 scoped_refptr<extensions::Extension> updated_app = |
| 384 MakeApp("Updated App1 Name", "2.0", "http://localhost/", "app_1"); |
| 385 manager()->UpdateAppDataFromProfile( |
| 386 "app_1", browser()->profile(), updated_app.get()); |
| 387 |
| 388 waiter.Wait(); |
| 389 EXPECT_TRUE(waiter.loaded()); |
| 390 |
| 391 manager()->GetApps(&apps); |
| 392 EXPECT_EQ(1u, apps.size()); |
| 393 EXPECT_EQ("app_1", apps[0].app_id); |
| 394 EXPECT_EQ("Updated App1 Name", apps[0].name); |
290 } | 395 } |
291 | 396 |
292 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, BadApp) { | 397 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, BadApp) { |
293 manager()->AddApp("unknown_app"); | 398 manager()->AddApp("unknown_app"); |
294 | 399 |
295 TestKioskAppManagerObserver observer(manager()); | 400 TestKioskAppManagerObserver observer(manager()); |
296 | 401 |
297 AppDataLoadWaiter waiter(manager()); | 402 AppDataLoadWaiter waiter(manager()); |
298 waiter.Wait(); | 403 waiter.Wait(); |
299 EXPECT_FALSE(waiter.loaded()); | 404 EXPECT_FALSE(waiter.loaded()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 new content::MessageLoopRunner; | 511 new content::MessageLoopRunner; |
407 manager()->GetConsumerKioskModeStatus( | 512 manager()->GetConsumerKioskModeStatus( |
408 base::Bind(&ConsumerKioskModeStatusCheck, | 513 base::Bind(&ConsumerKioskModeStatusCheck, |
409 status.get(), | 514 status.get(), |
410 runner3->QuitClosure())); | 515 runner3->QuitClosure())); |
411 runner3->Run(); | 516 runner3->Run(); |
412 EXPECT_EQ(*status.get(), KioskAppManager::CONSUMER_KIOSK_MODE_DISABLED); | 517 EXPECT_EQ(*status.get(), KioskAppManager::CONSUMER_KIOSK_MODE_DISABLED); |
413 } | 518 } |
414 | 519 |
415 } // namespace chromeos | 520 } // namespace chromeos |
OLD | NEW |