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