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

Side by Side Diff: chrome/browser/chromeos/app_mode/kiosk_app_manager_browsertest.cc

Issue 285253002: kiosk: Remove all cached CRX when removing a kiosk app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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/file_util.h" 8 #include "base/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"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
24 #include "chrome/test/base/in_process_browser_test.h" 24 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chromeos/settings/cros_settings_names.h" 25 #include "chromeos/settings/cros_settings_names.h"
26 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
27 #include "extensions/common/extension.h" 27 #include "extensions/common/extension.h"
28 #include "net/base/host_port_pair.h" 28 #include "net/base/host_port_pair.h"
29 #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" 30 #include "net/test/embedded_test_server/embedded_test_server.h"
31 31
32 using content::BrowserThread;
33
32 namespace chromeos { 34 namespace chromeos {
33 35
34 namespace { 36 namespace {
35 37
36 // An app to test local fs data persistence across app update. V1 app writes 38 // An app to test local fs data persistence across app update. V1 app writes
37 // data into local fs. V2 app reads and verifies the data. 39 // data into local fs. V2 app reads and verifies the data.
38 // Webstore data json is in 40 // Webstore data json is in
39 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ 41 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/
40 // detail/bmbpicmpniaclbbpdkfglgipkkebnbjf 42 // detail/bmbpicmpniaclbbpdkfglgipkkebnbjf
41 // The version 1.0.0 installed is in 43 // The version 1.0.0 installed is in
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 manager()->GetApps(&apps); 544 manager()->GetApps(&apps);
543 ASSERT_EQ(1u, apps.size()); 545 ASSERT_EQ(1u, apps.size());
544 base::FilePath crx_path; 546 base::FilePath crx_path;
545 std::string version; 547 std::string version;
546 EXPECT_TRUE(GetCachedCrx(kTestLocalFsKioskApp, &crx_path, &version)); 548 EXPECT_TRUE(GetCachedCrx(kTestLocalFsKioskApp, &crx_path, &version));
547 EXPECT_TRUE(base::PathExists(crx_path)); 549 EXPECT_TRUE(base::PathExists(crx_path));
548 EXPECT_EQ("1.0.0", version); 550 EXPECT_EQ("1.0.0", version);
549 551
550 // Remove the app now. 552 // Remove the app now.
551 manager()->RemoveApp(kTestLocalFsKioskApp); 553 manager()->RemoveApp(kTestLocalFsKioskApp);
554 content::RunAllPendingInMessageLoop(BrowserThread::FILE);
552 manager()->GetApps(&apps); 555 manager()->GetApps(&apps);
553 ASSERT_EQ(0u, apps.size()); 556 ASSERT_EQ(0u, apps.size());
554 EXPECT_FALSE(base::PathExists(crx_path)); 557 EXPECT_FALSE(base::PathExists(crx_path));
555 EXPECT_FALSE(GetCachedCrx(kTestLocalFsKioskApp, &crx_path, &version)); 558 EXPECT_FALSE(GetCachedCrx(kTestLocalFsKioskApp, &crx_path, &version));
556 } 559 }
557 560
558 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, UpdateApp) { 561 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, UpdateApp) {
559 // Add a version 1 app first. 562 // Add a version 1 app first.
560 RunAddNewAppTest(kTestLocalFsKioskApp, "1.0.0", kTestLocalFsKioskAppName); 563 RunAddNewAppTest(kTestLocalFsKioskApp, "1.0.0", kTestLocalFsKioskAppName);
561 KioskAppManager::Apps apps; 564 KioskAppManager::Apps apps;
(...skipping 26 matching lines...) Expand all
588 // Get original version 2 source download crx file path. 591 // Get original version 2 source download crx file path.
589 base::FilePath test_data_dir; 592 base::FilePath test_data_dir;
590 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); 593 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
591 base::FilePath v2_file_path = test_data_dir.Append(FILE_PATH_LITERAL( 594 base::FilePath v2_file_path = test_data_dir.Append(FILE_PATH_LITERAL(
592 "chromeos/app_mode/webstore/downloads/" 595 "chromeos/app_mode/webstore/downloads/"
593 "bmbpicmpniaclbbpdkfglgipkkebnbjf_v2_read_and_verify_data.crx")); 596 "bmbpicmpniaclbbpdkfglgipkkebnbjf_v2_read_and_verify_data.crx"));
594 EXPECT_TRUE(base::PathExists(v2_file_path)); 597 EXPECT_TRUE(base::PathExists(v2_file_path));
595 EXPECT_TRUE(base::ContentsEqual(v2_file_path, new_crx_path)); 598 EXPECT_TRUE(base::ContentsEqual(v2_file_path, new_crx_path));
596 } 599 }
597 600
601 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, UpdateAndRemoveApp) {
602 // Add a version 1 app first.
603 RunAddNewAppTest(kTestLocalFsKioskApp, "1.0.0", kTestLocalFsKioskAppName);
604 KioskAppManager::Apps apps;
605 manager()->GetApps(&apps);
606 ASSERT_EQ(1u, apps.size());
607 base::FilePath v1_crx_path;
608 std::string version;
609 EXPECT_TRUE(GetCachedCrx(kTestLocalFsKioskApp, &v1_crx_path, &version));
610 EXPECT_TRUE(base::PathExists(v1_crx_path));
611 EXPECT_EQ("1.0.0", version);
612
613 // Update to version 2.
614 fake_cws()->SetUpdateCrx(
615 kTestLocalFsKioskApp,
616 "bmbpicmpniaclbbpdkfglgipkkebnbjf_v2_read_and_verify_data.crx",
617 "2.0.0");
618 AppDataLoadWaiter waiter(manager(), 1);
619 UpdateAppData();
620 waiter.Wait();
621 EXPECT_TRUE(waiter.loaded());
622
623 // Verify the app has been updated to v2.
624 manager()->GetApps(&apps);
625 ASSERT_EQ(1u, apps.size());
626 base::FilePath v2_crx_path;
627 std::string new_version;
628 EXPECT_TRUE(GetCachedCrx(kTestLocalFsKioskApp, &v2_crx_path, &new_version));
629 EXPECT_EQ("2.0.0", new_version);
630 // Verify both v1 and v2 crx files exist.
631 EXPECT_TRUE(base::PathExists(v1_crx_path));
632 EXPECT_TRUE(base::PathExists(v2_crx_path));
633
634 // Remove the app now.
635 manager()->RemoveApp(kTestLocalFsKioskApp);
636 content::RunAllPendingInMessageLoop(BrowserThread::FILE);
637 manager()->GetApps(&apps);
638 ASSERT_EQ(0u, apps.size());
639 // Verify both v1 and v2 crx files are removed.
640 EXPECT_FALSE(base::PathExists(v1_crx_path));
641 EXPECT_FALSE(base::PathExists(v2_crx_path));
642 EXPECT_FALSE(GetCachedCrx(kTestLocalFsKioskApp, &v2_crx_path, &version));
643 }
644
598 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, EnableConsumerKiosk) { 645 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, EnableConsumerKiosk) {
599 scoped_ptr<KioskAppManager::ConsumerKioskAutoLaunchStatus> status( 646 scoped_ptr<KioskAppManager::ConsumerKioskAutoLaunchStatus> status(
600 new KioskAppManager::ConsumerKioskAutoLaunchStatus( 647 new KioskAppManager::ConsumerKioskAutoLaunchStatus(
601 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED)); 648 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED));
602 scoped_ptr<bool> locked(new bool(false)); 649 scoped_ptr<bool> locked(new bool(false));
603 650
604 scoped_refptr<content::MessageLoopRunner> runner = 651 scoped_refptr<content::MessageLoopRunner> runner =
605 new content::MessageLoopRunner; 652 new content::MessageLoopRunner;
606 manager()->GetConsumerKioskAutoLaunchStatus( 653 manager()->GetConsumerKioskAutoLaunchStatus(
607 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, 654 base::Bind(&ConsumerKioskAutoLaunchStatusCheck,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 manager()->GetConsumerKioskAutoLaunchStatus( 713 manager()->GetConsumerKioskAutoLaunchStatus(
667 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, 714 base::Bind(&ConsumerKioskAutoLaunchStatusCheck,
668 status.get(), 715 status.get(),
669 runner3->QuitClosure())); 716 runner3->QuitClosure()));
670 runner3->Run(); 717 runner3->Run();
671 EXPECT_EQ(*status.get(), 718 EXPECT_EQ(*status.get(),
672 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED); 719 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED);
673 } 720 }
674 721
675 } // namespace chromeos 722 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698