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

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

Issue 8176001: Warn user in case extension delays network traffic too much. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed Glen's comments Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 2681 matching lines...) Expand 10 before | Expand all | Expand 10 after
2692 UninstallExtension(good_crx, true); 2692 UninstallExtension(good_crx, true);
2693 } 2693 }
2694 2694
2695 TEST_F(ExtensionServiceTest, UninstallExtensionHelperTerminated) { 2695 TEST_F(ExtensionServiceTest, UninstallExtensionHelperTerminated) {
2696 InitializeEmptyExtensionService(); 2696 InitializeEmptyExtensionService();
2697 InstallCrx(data_dir_.AppendASCII("good.crx"), true); 2697 InstallCrx(data_dir_.AppendASCII("good.crx"), true);
2698 TerminateExtension(good_crx); 2698 TerminateExtension(good_crx);
2699 UninstallExtension(good_crx, true); 2699 UninstallExtension(good_crx, true);
2700 } 2700 }
2701 2701
2702 TEST_F(ExtensionServiceTest, TestExtensionWarnings) {
2703 InitializeEmptyExtensionService();
2704 EXPECT_EQ(0u, service_->GetWarnings().size());
2705
2706 // Simple extension that should install without error.
2707 FilePath path = data_dir_.AppendASCII("good.crx");
2708 InstallCrx(path, true);
2709 const char* extension_id = good_crx;
2710 std::set<std::string> extension_id_set;
2711 extension_id_set.insert(extension_id);
2712
2713 ExtensionServiceWarning warning(
2714 ExtensionServiceWarning::kExcessiveNetworkDelay, extension_id_set);
2715 EXPECT_TRUE(warning.AffectsExtension(good_crx));
2716 EXPECT_FALSE(warning.AffectsExtension("foobar"));
2717 EXPECT_EQ(ExtensionServiceWarning::kExcessiveNetworkDelay,
2718 warning.warning_type());
2719
2720 // Install warning.
2721 service_->SetWarning(warning);
2722 EXPECT_EQ(1u, service_->GetWarnings().size());
2723 EXPECT_TRUE(
2724 service_->HasWarning(ExtensionServiceWarning::kExcessiveNetworkDelay));
2725
2726 // Clear warning and check that is is gone.
2727 service_->ClearWarning(ExtensionServiceWarning::kExcessiveNetworkDelay);
2728 EXPECT_EQ(0u, service_->GetWarnings().size());
2729 EXPECT_FALSE(
2730 service_->HasWarning(ExtensionServiceWarning::kExcessiveNetworkDelay));
2731
2732 // Install warning and disable extension. Check that the warning is gone.
2733 service_->SetWarning(warning);
2734 service_->DisableExtension(extension_id);
2735 EXPECT_EQ(0u, service_->GetWarnings().size());
2736 }
2737
2702 class ExtensionCookieCallback { 2738 class ExtensionCookieCallback {
2703 public: 2739 public:
2704 ExtensionCookieCallback() 2740 ExtensionCookieCallback()
2705 : result_(false), 2741 : result_(false),
2706 message_loop_factory_(MessageLoop::current()) {} 2742 message_loop_factory_(MessageLoop::current()) {}
2707 2743
2708 void SetCookieCallback(bool result) { 2744 void SetCookieCallback(bool result) {
2709 MessageLoop::current()->PostTask( 2745 MessageLoop::current()->PostTask(
2710 FROM_HERE, 2746 FROM_HERE,
2711 message_loop_factory_.NewRunnableMethod(&MessageLoop::Quit)); 2747 message_loop_factory_.NewRunnableMethod(&MessageLoop::Quit));
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
4154 ASSERT_FALSE(AddPendingSyncInstall()); 4190 ASSERT_FALSE(AddPendingSyncInstall());
4155 4191
4156 // Wait for the external source to install. 4192 // Wait for the external source to install.
4157 WaitForCrxInstall(crx_path_, true); 4193 WaitForCrxInstall(crx_path_, true);
4158 ASSERT_TRUE(IsCrxInstalled()); 4194 ASSERT_TRUE(IsCrxInstalled());
4159 4195
4160 // Now that the extension is installed, sync request should fail 4196 // Now that the extension is installed, sync request should fail
4161 // because the extension is already installed. 4197 // because the extension is already installed.
4162 ASSERT_FALSE(AddPendingSyncInstall()); 4198 ASSERT_FALSE(AddPendingSyncInstall());
4163 } 4199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698