| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 12 #include "base/prefs/scoped_user_pref_update.h" | 13 #include "base/prefs/scoped_user_pref_update.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/app_mode/fake_cws.h" | 17 #include "chrome/browser/chromeos/app_mode/fake_cws.h" |
| 17 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" | 18 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" |
| 19 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" |
| 18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 19 #include "chrome/browser/chromeos/policy/device_local_account.h" | 21 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 20 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" |
| 21 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 26 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "chromeos/settings/cros_settings_names.h" | 27 #include "chromeos/settings/cros_settings_names.h" |
| 26 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| 27 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
| 28 #include "net/base/host_port_pair.h" | 30 #include "net/base/host_port_pair.h" |
| 29 #include "net/dns/mock_host_resolver.h" | 31 #include "net/dns/mock_host_resolver.h" |
| 30 #include "net/test/embedded_test_server/embedded_test_server.h" | 32 #include "net/test/embedded_test_server/embedded_test_server.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 int data_change_count_; | 160 int data_change_count_; |
| 159 int data_loaded_threshold_; | 161 int data_loaded_threshold_; |
| 160 | 162 |
| 161 DISALLOW_COPY_AND_ASSIGN(AppDataLoadWaiter); | 163 DISALLOW_COPY_AND_ASSIGN(AppDataLoadWaiter); |
| 162 }; | 164 }; |
| 163 | 165 |
| 164 } // namespace | 166 } // namespace |
| 165 | 167 |
| 166 class KioskAppManagerTest : public InProcessBrowserTest { | 168 class KioskAppManagerTest : public InProcessBrowserTest { |
| 167 public: | 169 public: |
| 168 KioskAppManagerTest() : fake_cws_(new FakeCWS()) {} | 170 KioskAppManagerTest() : settings_helper_(false), fake_cws_(new FakeCWS()) {} |
| 169 ~KioskAppManagerTest() override {} | 171 ~KioskAppManagerTest() override {} |
| 170 | 172 |
| 171 // InProcessBrowserTest overrides: | 173 // InProcessBrowserTest overrides: |
| 172 void SetUp() override { | 174 void SetUp() override { |
| 173 base::FilePath test_data_dir; | 175 base::FilePath test_data_dir; |
| 174 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); | 176 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
| 175 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); | 177 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); |
| 176 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 178 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 177 // Stop IO thread here because no threads are allowed while | 179 // Stop IO thread here because no threads are allowed while |
| 178 // spawning sandbox host process. See crbug.com/322732. | 180 // spawning sandbox host process. See crbug.com/322732. |
| 179 embedded_test_server()->StopThread(); | 181 embedded_test_server()->StopThread(); |
| 180 | 182 |
| 181 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 183 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 182 | 184 |
| 183 InProcessBrowserTest::SetUp(); | 185 InProcessBrowserTest::SetUp(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 void SetUpCommandLine(base::CommandLine* command_line) override { | 188 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 187 InProcessBrowserTest::SetUpCommandLine(command_line); | 189 InProcessBrowserTest::SetUpCommandLine(command_line); |
| 188 | 190 |
| 189 // Initialize fake_cws_ to setup web store gallery. | 191 // Initialize fake_cws_ to setup web store gallery. |
| 190 fake_cws_->Init(embedded_test_server()); | 192 fake_cws_->Init(embedded_test_server()); |
| 191 } | 193 } |
| 192 | 194 |
| 193 void SetUpOnMainThread() override { | 195 void SetUpOnMainThread() override { |
| 194 InProcessBrowserTest::SetUpOnMainThread(); | 196 InProcessBrowserTest::SetUpOnMainThread(); |
| 195 | 197 |
| 196 // Restart the thread as the sandbox host process has already been spawned. | 198 // Restart the thread as the sandbox host process has already been spawned. |
| 197 embedded_test_server()->RestartThreadAndListen(); | 199 embedded_test_server()->RestartThreadAndListen(); |
| 200 |
| 201 settings_helper_.ReplaceProvider(kAccountsPrefDeviceLocalAccounts); |
| 202 owner_settings_service_.reset( |
| 203 settings_helper_.CreateOwnerSettingsService(browser()->profile())); |
| 198 } | 204 } |
| 199 | 205 |
| 206 void TearDownOnMainThread() override { settings_helper_.RestoreProvider(); } |
| 207 |
| 200 void SetUpInProcessBrowserTestFixture() override { | 208 void SetUpInProcessBrowserTestFixture() override { |
| 201 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | 209 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 202 | 210 |
| 203 host_resolver()->AddRule("*", "127.0.0.1"); | 211 host_resolver()->AddRule("*", "127.0.0.1"); |
| 204 } | 212 } |
| 205 | 213 |
| 206 std::string GetAppIds() const { | 214 std::string GetAppIds() const { |
| 207 KioskAppManager::Apps apps; | 215 KioskAppManager::Apps apps; |
| 208 manager()->GetApps(&apps); | 216 manager()->GetApps(&apps); |
| 209 | 217 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 entry->SetStringWithoutPathExpansion( | 271 entry->SetStringWithoutPathExpansion( |
| 264 kAccountsPrefDeviceLocalAccountsKeyId, | 272 kAccountsPrefDeviceLocalAccountsKeyId, |
| 265 app_id + "_id"); | 273 app_id + "_id"); |
| 266 entry->SetIntegerWithoutPathExpansion( | 274 entry->SetIntegerWithoutPathExpansion( |
| 267 kAccountsPrefDeviceLocalAccountsKeyType, | 275 kAccountsPrefDeviceLocalAccountsKeyType, |
| 268 policy::DeviceLocalAccount::TYPE_KIOSK_APP); | 276 policy::DeviceLocalAccount::TYPE_KIOSK_APP); |
| 269 entry->SetStringWithoutPathExpansion( | 277 entry->SetStringWithoutPathExpansion( |
| 270 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, | 278 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, |
| 271 app_id); | 279 app_id); |
| 272 device_local_accounts.Append(entry.release()); | 280 device_local_accounts.Append(entry.release()); |
| 273 CrosSettings::Get()->Set(kAccountsPrefDeviceLocalAccounts, | 281 owner_settings_service_->Set(kAccountsPrefDeviceLocalAccounts, |
| 274 device_local_accounts); | 282 device_local_accounts); |
| 275 } | 283 } |
| 276 | 284 |
| 277 bool GetCachedCrx(const std::string& app_id, | 285 bool GetCachedCrx(const std::string& app_id, |
| 278 base::FilePath* file_path, | 286 base::FilePath* file_path, |
| 279 std::string* version) { | 287 std::string* version) { |
| 280 return manager()->GetCachedCrx(app_id, file_path, version); | 288 return manager()->GetCachedCrx(app_id, file_path, version); |
| 281 } | 289 } |
| 282 | 290 |
| 283 void UpdateAppData() { manager()->UpdateAppData(); } | 291 void UpdateAppData() { manager()->UpdateAppData(); } |
| 284 | 292 |
| 285 void RunAddNewAppTest(const std::string& id, | 293 void RunAddNewAppTest(const std::string& id, |
| 286 const std::string& version, | 294 const std::string& version, |
| 287 const std::string& app_name) { | 295 const std::string& app_name) { |
| 288 std::string crx_file_name = id + ".crx"; | 296 std::string crx_file_name = id + ".crx"; |
| 289 fake_cws_->SetUpdateCrx(id, crx_file_name, version); | 297 fake_cws_->SetUpdateCrx(id, crx_file_name, version); |
| 290 | 298 |
| 291 AppDataLoadWaiter waiter(manager(), 3); | 299 AppDataLoadWaiter waiter(manager(), 3); |
| 292 manager()->AddApp(id); | 300 manager()->AddApp(id, owner_settings_service_.get()); |
| 293 waiter.Wait(); | 301 waiter.Wait(); |
| 294 EXPECT_TRUE(waiter.loaded()); | 302 EXPECT_TRUE(waiter.loaded()); |
| 295 | 303 |
| 296 // Check CRX file is cached. | 304 // Check CRX file is cached. |
| 297 base::FilePath crx_path; | 305 base::FilePath crx_path; |
| 298 std::string crx_version; | 306 std::string crx_version; |
| 299 EXPECT_TRUE(GetCachedCrx(id, &crx_path, &crx_version)); | 307 EXPECT_TRUE(GetCachedCrx(id, &crx_path, &crx_version)); |
| 300 EXPECT_TRUE(base::PathExists(crx_path)); | 308 EXPECT_TRUE(base::PathExists(crx_path)); |
| 301 EXPECT_EQ(version, crx_version); | 309 EXPECT_EQ(version, crx_version); |
| 302 // Verify the original crx file is identical to the cached file. | 310 // Verify the original crx file is identical to the cached file. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 expected_icon_path = | 343 expected_icon_path = |
| 336 expected_icon_path.AppendASCII(KioskAppManager::kIconCacheDir) | 344 expected_icon_path.AppendASCII(KioskAppManager::kIconCacheDir) |
| 337 .AppendASCII(apps[0].app_id) | 345 .AppendASCII(apps[0].app_id) |
| 338 .AddExtension(".png"); | 346 .AddExtension(".png"); |
| 339 EXPECT_EQ(expected_icon_path.value(), icon_path_string); | 347 EXPECT_EQ(expected_icon_path.value(), icon_path_string); |
| 340 } | 348 } |
| 341 | 349 |
| 342 KioskAppManager* manager() const { return KioskAppManager::Get(); } | 350 KioskAppManager* manager() const { return KioskAppManager::Get(); } |
| 343 FakeCWS* fake_cws() { return fake_cws_.get(); } | 351 FakeCWS* fake_cws() { return fake_cws_.get(); } |
| 344 | 352 |
| 353 protected: |
| 354 ScopedCrosSettingsTestHelper settings_helper_; |
| 355 scoped_ptr<FakeOwnerSettingsService> owner_settings_service_; |
| 356 |
| 345 private: | 357 private: |
| 346 base::ScopedTempDir temp_dir_; | 358 base::ScopedTempDir temp_dir_; |
| 347 scoped_ptr<FakeCWS> fake_cws_; | 359 scoped_ptr<FakeCWS> fake_cws_; |
| 348 | 360 |
| 349 DISALLOW_COPY_AND_ASSIGN(KioskAppManagerTest); | 361 DISALLOW_COPY_AND_ASSIGN(KioskAppManagerTest); |
| 350 }; | 362 }; |
| 351 | 363 |
| 352 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, Basic) { | 364 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, Basic) { |
| 353 // Add a couple of apps. Use "fake_app_x" that do not have data on the test | 365 // Add a couple of apps. Use "fake_app_x" that do not have data on the test |
| 354 // server to avoid pending data loads that could be lingering on tear down and | 366 // server to avoid pending data loads that could be lingering on tear down and |
| 355 // cause DCHECK failure in utility_process_host_impl.cc. | 367 // cause DCHECK failure in utility_process_host_impl.cc. |
| 356 manager()->AddApp("fake_app_1"); | 368 manager()->AddApp("fake_app_1", owner_settings_service_.get()); |
| 357 manager()->AddApp("fake_app_2"); | 369 manager()->AddApp("fake_app_2", owner_settings_service_.get()); |
| 358 EXPECT_EQ("fake_app_1,fake_app_2", GetAppIds()); | 370 EXPECT_EQ("fake_app_1,fake_app_2", GetAppIds()); |
| 359 | 371 |
| 360 // Set an auto launch app. | 372 // Set an auto launch app. |
| 361 manager()->SetAutoLaunchApp("fake_app_1"); | 373 manager()->SetAutoLaunchApp("fake_app_1", owner_settings_service_.get()); |
| 362 EXPECT_EQ("fake_app_1", manager()->GetAutoLaunchApp()); | 374 EXPECT_EQ("fake_app_1", manager()->GetAutoLaunchApp()); |
| 363 | 375 |
| 364 // Make sure that if an app was auto launched with zero delay, it is reflected | 376 // Make sure that if an app was auto launched with zero delay, it is reflected |
| 365 // in the app data. | 377 // in the app data. |
| 366 KioskAppManager::App app; | 378 KioskAppManager::App app; |
| 367 manager()->GetApp("fake_app_1", &app); | 379 manager()->GetApp("fake_app_1", &app); |
| 368 EXPECT_FALSE(app.was_auto_launched_with_zero_delay); | 380 EXPECT_FALSE(app.was_auto_launched_with_zero_delay); |
| 369 | 381 |
| 370 manager()->SetAppWasAutoLaunchedWithZeroDelay("fake_app_1"); | 382 manager()->SetAppWasAutoLaunchedWithZeroDelay("fake_app_1"); |
| 371 manager()->GetApp("fake_app_1", &app); | 383 manager()->GetApp("fake_app_1", &app); |
| 372 EXPECT_TRUE(app.was_auto_launched_with_zero_delay); | 384 EXPECT_TRUE(app.was_auto_launched_with_zero_delay); |
| 373 | 385 |
| 374 // Clear the auto launch app. | 386 // Clear the auto launch app. |
| 375 manager()->SetAutoLaunchApp(""); | 387 manager()->SetAutoLaunchApp("", owner_settings_service_.get()); |
| 376 EXPECT_EQ("", manager()->GetAutoLaunchApp()); | 388 EXPECT_EQ("", manager()->GetAutoLaunchApp()); |
| 377 EXPECT_FALSE(manager()->IsAutoLaunchEnabled()); | 389 EXPECT_FALSE(manager()->IsAutoLaunchEnabled()); |
| 378 | 390 |
| 379 // App should still report it was auto launched with zero delay, even though | 391 // App should still report it was auto launched with zero delay, even though |
| 380 // it is no longer set to auto launch in the future. | 392 // it is no longer set to auto launch in the future. |
| 381 manager()->GetApp("fake_app_1", &app); | 393 manager()->GetApp("fake_app_1", &app); |
| 382 EXPECT_TRUE(app.was_auto_launched_with_zero_delay); | 394 EXPECT_TRUE(app.was_auto_launched_with_zero_delay); |
| 383 | 395 |
| 384 // Set another auto launch app. | 396 // Set another auto launch app. |
| 385 manager()->SetAutoLaunchApp("fake_app_2"); | 397 manager()->SetAutoLaunchApp("fake_app_2", owner_settings_service_.get()); |
| 386 EXPECT_EQ("fake_app_2", manager()->GetAutoLaunchApp()); | 398 EXPECT_EQ("fake_app_2", manager()->GetAutoLaunchApp()); |
| 387 | 399 |
| 388 // Check auto launch permissions. | 400 // Check auto launch permissions. |
| 389 EXPECT_FALSE(manager()->IsAutoLaunchEnabled()); | 401 EXPECT_FALSE(manager()->IsAutoLaunchEnabled()); |
| 390 manager()->SetEnableAutoLaunch(true); | 402 manager()->SetEnableAutoLaunch(true); |
| 391 EXPECT_TRUE(manager()->IsAutoLaunchEnabled()); | 403 EXPECT_TRUE(manager()->IsAutoLaunchEnabled()); |
| 392 | 404 |
| 393 // Remove the auto launch app. | 405 // Remove the auto launch app. |
| 394 manager()->RemoveApp("fake_app_2"); | 406 manager()->RemoveApp("fake_app_2", owner_settings_service_.get()); |
| 395 EXPECT_EQ("fake_app_1", GetAppIds()); | 407 EXPECT_EQ("fake_app_1", GetAppIds()); |
| 396 EXPECT_EQ("", manager()->GetAutoLaunchApp()); | 408 EXPECT_EQ("", manager()->GetAutoLaunchApp()); |
| 397 | 409 |
| 398 // Add the just removed auto launch app again and it should no longer be | 410 // Add the just removed auto launch app again and it should no longer be |
| 399 // the auto launch app. | 411 // the auto launch app. |
| 400 manager()->AddApp("fake_app_2"); | 412 manager()->AddApp("fake_app_2", owner_settings_service_.get()); |
| 401 EXPECT_EQ("", manager()->GetAutoLaunchApp()); | 413 EXPECT_EQ("", manager()->GetAutoLaunchApp()); |
| 402 manager()->RemoveApp("fake_app_2"); | 414 manager()->RemoveApp("fake_app_2", owner_settings_service_.get()); |
| 403 EXPECT_EQ("fake_app_1", GetAppIds()); | 415 EXPECT_EQ("fake_app_1", GetAppIds()); |
| 404 | 416 |
| 405 // Set a none exist app as auto launch. | 417 // Set a none exist app as auto launch. |
| 406 manager()->SetAutoLaunchApp("none_exist_app"); | 418 manager()->SetAutoLaunchApp("none_exist_app", owner_settings_service_.get()); |
| 407 EXPECT_EQ("", manager()->GetAutoLaunchApp()); | 419 EXPECT_EQ("", manager()->GetAutoLaunchApp()); |
| 408 EXPECT_FALSE(manager()->IsAutoLaunchEnabled()); | 420 EXPECT_FALSE(manager()->IsAutoLaunchEnabled()); |
| 409 | 421 |
| 410 // Add an existing app again. | 422 // Add an existing app again. |
| 411 manager()->AddApp("fake_app_1"); | 423 manager()->AddApp("fake_app_1", owner_settings_service_.get()); |
| 412 EXPECT_EQ("fake_app_1", GetAppIds()); | 424 EXPECT_EQ("fake_app_1", GetAppIds()); |
| 413 } | 425 } |
| 414 | 426 |
| 415 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, LoadCached) { | 427 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, LoadCached) { |
| 416 SetExistingApp("app_1", "Cached App1 Name", "red16x16.png"); | 428 SetExistingApp("app_1", "Cached App1 Name", "red16x16.png"); |
| 417 | 429 |
| 418 fake_cws()->SetNoUpdate("app_1"); | 430 fake_cws()->SetNoUpdate("app_1"); |
| 419 AppDataLoadWaiter waiter(manager(), 1); | 431 AppDataLoadWaiter waiter(manager(), 1); |
| 420 waiter.Wait(); | 432 waiter.Wait(); |
| 421 EXPECT_TRUE(waiter.loaded()); | 433 EXPECT_TRUE(waiter.loaded()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 EXPECT_TRUE(waiter.loaded()); | 478 EXPECT_TRUE(waiter.loaded()); |
| 467 | 479 |
| 468 manager()->GetApps(&apps); | 480 manager()->GetApps(&apps); |
| 469 EXPECT_EQ(1u, apps.size()); | 481 EXPECT_EQ(1u, apps.size()); |
| 470 EXPECT_EQ("app_1", apps[0].app_id); | 482 EXPECT_EQ("app_1", apps[0].app_id); |
| 471 EXPECT_EQ("Updated App1 Name", apps[0].name); | 483 EXPECT_EQ("Updated App1 Name", apps[0].name); |
| 472 } | 484 } |
| 473 | 485 |
| 474 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, BadApp) { | 486 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, BadApp) { |
| 475 AppDataLoadWaiter waiter(manager(), 2); | 487 AppDataLoadWaiter waiter(manager(), 2); |
| 476 manager()->AddApp("unknown_app"); | 488 manager()->AddApp("unknown_app", owner_settings_service_.get()); |
| 477 waiter.Wait(); | 489 waiter.Wait(); |
| 478 EXPECT_FALSE(waiter.loaded()); | 490 EXPECT_FALSE(waiter.loaded()); |
| 479 EXPECT_EQ("", GetAppIds()); | 491 EXPECT_EQ("", GetAppIds()); |
| 480 } | 492 } |
| 481 | 493 |
| 482 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, GoodApp) { | 494 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, GoodApp) { |
| 483 // Webstore data json is in | 495 // Webstore data json is in |
| 484 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/detail/app_1 | 496 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/detail/app_1 |
| 485 fake_cws()->SetNoUpdate("app_1"); | 497 fake_cws()->SetNoUpdate("app_1"); |
| 486 AppDataLoadWaiter waiter(manager(), 2); | 498 AppDataLoadWaiter waiter(manager(), 2); |
| 487 manager()->AddApp("app_1"); | 499 manager()->AddApp("app_1", owner_settings_service_.get()); |
| 488 waiter.Wait(); | 500 waiter.Wait(); |
| 489 EXPECT_TRUE(waiter.loaded()); | 501 EXPECT_TRUE(waiter.loaded()); |
| 490 | 502 |
| 491 // Check data is correct. | 503 // Check data is correct. |
| 492 KioskAppManager::Apps apps; | 504 KioskAppManager::Apps apps; |
| 493 manager()->GetApps(&apps); | 505 manager()->GetApps(&apps); |
| 494 ASSERT_EQ(1u, apps.size()); | 506 ASSERT_EQ(1u, apps.size()); |
| 495 EXPECT_EQ("app_1", apps[0].app_id); | 507 EXPECT_EQ("app_1", apps[0].app_id); |
| 496 EXPECT_EQ("Name of App 1", apps[0].name); | 508 EXPECT_EQ("Name of App 1", apps[0].name); |
| 497 EXPECT_EQ(gfx::Size(16, 16), apps[0].icon.size()); | 509 EXPECT_EQ(gfx::Size(16, 16), apps[0].icon.size()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 526 KioskAppManager::Apps apps; | 538 KioskAppManager::Apps apps; |
| 527 manager()->GetApps(&apps); | 539 manager()->GetApps(&apps); |
| 528 ASSERT_EQ(1u, apps.size()); | 540 ASSERT_EQ(1u, apps.size()); |
| 529 base::FilePath crx_path; | 541 base::FilePath crx_path; |
| 530 std::string version; | 542 std::string version; |
| 531 EXPECT_TRUE(GetCachedCrx(kTestLocalFsKioskApp, &crx_path, &version)); | 543 EXPECT_TRUE(GetCachedCrx(kTestLocalFsKioskApp, &crx_path, &version)); |
| 532 EXPECT_TRUE(base::PathExists(crx_path)); | 544 EXPECT_TRUE(base::PathExists(crx_path)); |
| 533 EXPECT_EQ("1.0.0", version); | 545 EXPECT_EQ("1.0.0", version); |
| 534 | 546 |
| 535 // Remove the app now. | 547 // Remove the app now. |
| 536 manager()->RemoveApp(kTestLocalFsKioskApp); | 548 manager()->RemoveApp(kTestLocalFsKioskApp, owner_settings_service_.get()); |
| 537 content::RunAllBlockingPoolTasksUntilIdle(); | 549 content::RunAllBlockingPoolTasksUntilIdle(); |
| 538 manager()->GetApps(&apps); | 550 manager()->GetApps(&apps); |
| 539 ASSERT_EQ(0u, apps.size()); | 551 ASSERT_EQ(0u, apps.size()); |
| 540 EXPECT_FALSE(base::PathExists(crx_path)); | 552 EXPECT_FALSE(base::PathExists(crx_path)); |
| 541 EXPECT_FALSE(GetCachedCrx(kTestLocalFsKioskApp, &crx_path, &version)); | 553 EXPECT_FALSE(GetCachedCrx(kTestLocalFsKioskApp, &crx_path, &version)); |
| 542 } | 554 } |
| 543 | 555 |
| 544 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, UpdateApp) { | 556 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, UpdateApp) { |
| 545 // Add a version 1 app first. | 557 // Add a version 1 app first. |
| 546 RunAddNewAppTest(kTestLocalFsKioskApp, "1.0.0", kTestLocalFsKioskAppName); | 558 RunAddNewAppTest(kTestLocalFsKioskApp, "1.0.0", kTestLocalFsKioskAppName); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 ASSERT_EQ(1u, apps.size()); | 620 ASSERT_EQ(1u, apps.size()); |
| 609 base::FilePath v2_crx_path; | 621 base::FilePath v2_crx_path; |
| 610 std::string new_version; | 622 std::string new_version; |
| 611 EXPECT_TRUE(GetCachedCrx(kTestLocalFsKioskApp, &v2_crx_path, &new_version)); | 623 EXPECT_TRUE(GetCachedCrx(kTestLocalFsKioskApp, &v2_crx_path, &new_version)); |
| 612 EXPECT_EQ("2.0.0", new_version); | 624 EXPECT_EQ("2.0.0", new_version); |
| 613 // Verify both v1 and v2 crx files exist. | 625 // Verify both v1 and v2 crx files exist. |
| 614 EXPECT_TRUE(base::PathExists(v1_crx_path)); | 626 EXPECT_TRUE(base::PathExists(v1_crx_path)); |
| 615 EXPECT_TRUE(base::PathExists(v2_crx_path)); | 627 EXPECT_TRUE(base::PathExists(v2_crx_path)); |
| 616 | 628 |
| 617 // Remove the app now. | 629 // Remove the app now. |
| 618 manager()->RemoveApp(kTestLocalFsKioskApp); | 630 manager()->RemoveApp(kTestLocalFsKioskApp, owner_settings_service_.get()); |
| 619 content::RunAllBlockingPoolTasksUntilIdle(); | 631 content::RunAllBlockingPoolTasksUntilIdle(); |
| 620 manager()->GetApps(&apps); | 632 manager()->GetApps(&apps); |
| 621 ASSERT_EQ(0u, apps.size()); | 633 ASSERT_EQ(0u, apps.size()); |
| 622 // Verify both v1 and v2 crx files are removed. | 634 // Verify both v1 and v2 crx files are removed. |
| 623 EXPECT_FALSE(base::PathExists(v1_crx_path)); | 635 EXPECT_FALSE(base::PathExists(v1_crx_path)); |
| 624 EXPECT_FALSE(base::PathExists(v2_crx_path)); | 636 EXPECT_FALSE(base::PathExists(v2_crx_path)); |
| 625 EXPECT_FALSE(GetCachedCrx(kTestLocalFsKioskApp, &v2_crx_path, &version)); | 637 EXPECT_FALSE(GetCachedCrx(kTestLocalFsKioskApp, &v2_crx_path, &version)); |
| 626 } | 638 } |
| 627 | 639 |
| 628 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, EnableConsumerKiosk) { | 640 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, EnableConsumerKiosk) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 manager()->GetConsumerKioskAutoLaunchStatus( | 708 manager()->GetConsumerKioskAutoLaunchStatus( |
| 697 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, | 709 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, |
| 698 status.get(), | 710 status.get(), |
| 699 runner3->QuitClosure())); | 711 runner3->QuitClosure())); |
| 700 runner3->Run(); | 712 runner3->Run(); |
| 701 EXPECT_EQ(*status.get(), | 713 EXPECT_EQ(*status.get(), |
| 702 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED); | 714 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED); |
| 703 } | 715 } |
| 704 | 716 |
| 705 } // namespace chromeos | 717 } // namespace chromeos |
| OLD | NEW |