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

Side by Side Diff: extensions/browser/runtime_data_unittest.cc

Issue 2442213003: Remove dead extensions tracking code. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 | « extensions/browser/runtime_data.cc ('k') | extensions/common/extension_messages.h » ('j') | 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 "extensions/browser/runtime_data.h" 5 #include "extensions/browser/runtime_data.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // An extension is not being upgraded until the flag is set. 67 // An extension is not being upgraded until the flag is set.
68 EXPECT_FALSE(runtime_data_.IsBeingUpgraded(extension->id())); 68 EXPECT_FALSE(runtime_data_.IsBeingUpgraded(extension->id()));
69 69
70 // The flag can be toggled. 70 // The flag can be toggled.
71 runtime_data_.SetBeingUpgraded(extension->id(), true); 71 runtime_data_.SetBeingUpgraded(extension->id(), true);
72 EXPECT_TRUE(runtime_data_.IsBeingUpgraded(extension->id())); 72 EXPECT_TRUE(runtime_data_.IsBeingUpgraded(extension->id()));
73 runtime_data_.SetBeingUpgraded(extension->id(), false); 73 runtime_data_.SetBeingUpgraded(extension->id(), false);
74 EXPECT_FALSE(runtime_data_.IsBeingUpgraded(extension->id())); 74 EXPECT_FALSE(runtime_data_.IsBeingUpgraded(extension->id()));
75 } 75 }
76 76
77 TEST_F(RuntimeDataTest, HasUsedWebRequest) {
78 scoped_refptr<Extension> extension = test_util::CreateEmptyExtension();
79
80 // An extension has not used web request until the flag is set.
81 EXPECT_FALSE(runtime_data_.HasUsedWebRequest(extension->id()));
82
83 // The flag can be toggled.
84 runtime_data_.SetHasUsedWebRequest(extension->id(), true);
85 EXPECT_TRUE(runtime_data_.HasUsedWebRequest(extension->id()));
86 runtime_data_.SetHasUsedWebRequest(extension->id(), false);
87 EXPECT_FALSE(runtime_data_.HasUsedWebRequest(extension->id()));
88 }
89
90 // Unloading an extension erases any data that shouldn't explicitly be kept 77 // Unloading an extension erases any data that shouldn't explicitly be kept
91 // across loads. 78 // across loads.
92 TEST_F(RuntimeDataTest, OnExtensionUnloaded) { 79 TEST_F(RuntimeDataTest, OnExtensionUnloaded) {
93 scoped_refptr<Extension> extension = CreateExtensionWithBackgroundPage(); 80 scoped_refptr<Extension> extension = CreateExtensionWithBackgroundPage();
94 runtime_data_.SetBackgroundPageReady(extension->id(), true); 81 runtime_data_.SetBackgroundPageReady(extension->id(), true);
95 ASSERT_TRUE(runtime_data_.HasExtensionForTesting(extension->id())); 82 ASSERT_TRUE(runtime_data_.HasExtensionForTesting(extension->id()));
96 runtime_data_.SetBeingUpgraded(extension->id(), true); 83 runtime_data_.SetBeingUpgraded(extension->id(), true);
97 84
98 runtime_data_.OnExtensionUnloaded( 85 runtime_data_.OnExtensionUnloaded(
99 NULL, extension.get(), UnloadedExtensionInfo::REASON_DISABLE); 86 NULL, extension.get(), UnloadedExtensionInfo::REASON_DISABLE);
100 EXPECT_TRUE(runtime_data_.HasExtensionForTesting(extension->id())); 87 EXPECT_TRUE(runtime_data_.HasExtensionForTesting(extension->id()));
101 EXPECT_FALSE(runtime_data_.IsBackgroundPageReady(extension.get())); 88 EXPECT_FALSE(runtime_data_.IsBackgroundPageReady(extension.get()));
102 EXPECT_TRUE(runtime_data_.IsBeingUpgraded(extension->id())); 89 EXPECT_TRUE(runtime_data_.IsBeingUpgraded(extension->id()));
103 } 90 }
104 91
105 } // namespace 92 } // namespace
106 } // namespace extensions 93 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/runtime_data.cc ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698