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

Side by Side Diff: chrome/browser/extensions/content_verifier_browsertest.cc

Issue 2537623002: Fix flaky test ContentVerifierPolicyTest.PolicyCorruptedOnStartup (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <list> 5 #include <list>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 700
701 protected: 701 protected:
702 // The id of the extension we want to have force-installed. 702 // The id of the extension we want to have force-installed.
703 std::string id_ = "npnbmohejbjohgpjnmjagbafnjhkmgko"; 703 std::string id_ = "npnbmohejbjohgpjnmjagbafnjhkmgko";
704 704
705 private: 705 private:
706 policy::MockConfigurationPolicyProvider policy_provider_; 706 policy::MockConfigurationPolicyProvider policy_provider_;
707 DownloaderTestDelegate downloader_; 707 DownloaderTestDelegate downloader_;
708 }; 708 };
709 709
710 // Disabled due to flakiness (crbug.com/668067)
711 // We want to test what happens at startup with a corroption-disabled policy 710 // We want to test what happens at startup with a corroption-disabled policy
712 // force installed extension. So we set that up in the PRE test here. 711 // force installed extension. So we set that up in the PRE test here.
713 IN_PROC_BROWSER_TEST_F(ContentVerifierPolicyTest, 712 IN_PROC_BROWSER_TEST_F(ContentVerifierPolicyTest,
714 DISABLED_PRE_PolicyCorruptedOnStartup) { 713 PRE_PolicyCorruptedOnStartup) {
715 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 714 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
716 RegistryObserver registry_observer(registry); 715 RegistryObserver registry_observer(registry);
717 716
718 // Wait for the extension to be installed by policy we set up in 717 // Wait for the extension to be installed by policy we set up in
719 // SetUpInProcessBrowserTestFixture. 718 // SetUpInProcessBrowserTestFixture.
720 if (!registry->GetInstalledExtension(id_)) { 719 if (!registry->GetInstalledExtension(id_)) {
721 EXPECT_TRUE(registry_observer.WaitForInstall(id_)); 720 EXPECT_TRUE(registry_observer.WaitForInstall(id_));
722 } 721 }
723 722
724 // Simulate corruption of the extension so that we can test what happens 723 // Simulate corruption of the extension so that we can test what happens
725 // at startup in the non-PRE test. 724 // at startup in the non-PRE test.
726 ExtensionSystem* system = ExtensionSystem::Get(profile()); 725 ExtensionSystem* system = ExtensionSystem::Get(profile());
727 ContentVerifier* verifier = system->content_verifier(); 726 ContentVerifier* verifier = system->content_verifier();
728 verifier->VerifyFailed(id_, ContentVerifyJob::HASH_MISMATCH); 727 verifier->VerifyFailed(id_, ContentVerifyJob::HASH_MISMATCH);
729 EXPECT_TRUE(registry_observer.WaitForUnload(id_)); 728 EXPECT_TRUE(registry_observer.WaitForUnload(id_));
730 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); 729 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile());
731 int reasons = prefs->GetDisableReasons(id_); 730 int reasons = prefs->GetDisableReasons(id_);
732 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED); 731 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED);
733 } 732 }
734 733
735 // Disabled due to flakiness (crbug.com/668067)
736 // Now actually test what happens on the next startup after the PRE test above. 734 // Now actually test what happens on the next startup after the PRE test above.
737 IN_PROC_BROWSER_TEST_F(ContentVerifierPolicyTest, 735 IN_PROC_BROWSER_TEST_F(ContentVerifierPolicyTest, PolicyCorruptedOnStartup) {
738 DISABLED_PolicyCorruptedOnStartup) { 736 // Depdending on timing, the extension may have already been reinstalled
739 // Expect that the extension is still disabled for corruption. 737 // between SetUpInProcessBrowserTestFixture and now (usually not during local
738 // testing on a developer machine, but sometimes on a heavily loaded system
739 // such as the build waterfall / trybots). If the reinstall didn't already
740 // happen, wait for it.
740 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); 741 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile());
741 int reasons = prefs->GetDisableReasons(id_); 742 int reasons = prefs->GetDisableReasons(id_);
742 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED); 743 if (reasons & Extension::DISABLE_CORRUPTED) {
743 744 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
744 // Now expect that it gets reinstalled (because a job should have been kicked 745 RegistryObserver registry_observer(registry);
745 // off by the installed extension loading code). 746 EXPECT_TRUE(registry_observer.WaitForInstall(id_));
746 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 747 reasons = prefs->GetDisableReasons(id_);
Devlin 2016/11/29 22:46:38 Could we end the test with checking the disable re
asargent_no_longer_on_chrome 2016/11/30 01:02:05 Good suggestion - done.
747 RegistryObserver registry_observer(registry); 748 EXPECT_FALSE(reasons & Extension::DISABLE_CORRUPTED);
748 EXPECT_TRUE(registry_observer.WaitForInstall(id_)); 749 }
749 reasons = prefs->GetDisableReasons(id_);
750 EXPECT_FALSE(reasons & Extension::DISABLE_CORRUPTED);
751 } 750 }
752 751
753 } // namespace extensions 752 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698