diff options
author | rdevlin.cronin <rdevlin.cronin@chromium.org> | 2014-11-20 17:35:49 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-21 01:36:05 +0000 |
commit | 2c16c6099f1f799509a19bacf6b04add78410e55 (patch) | |
tree | ff821051f07fd104d237869c374ed0c42c655cc2 /extensions/browser/runtime_data_unittest.cc | |
parent | 4167dc6b93bbcbee8b2503f8c57d7f16e4149c0c (diff) | |
download | chromium_src-2c16c6099f1f799509a19bacf6b04add78410e55.zip chromium_src-2c16c6099f1f799509a19bacf6b04add78410e55.tar.gz chromium_src-2c16c6099f1f799509a19bacf6b04add78410e55.tar.bz2 |
[Extensions] Fix IsBeingUpgraded runtime data bug and make RuntimeData take ids
Fix a bug where IsBeingUpgraded would be reset during the reload process (even
though it's also *set* during the reload process...), and make RuntimeData take
extension ids instead of extensions.
BUG=435336
TBR=sky@chromium.org (micro change in ui/toolbar/)
Review URL: https://codereview.chromium.org/743373002
Cr-Commit-Position: refs/heads/master@{#305134}
Diffstat (limited to 'extensions/browser/runtime_data_unittest.cc')
-rw-r--r-- | extensions/browser/runtime_data_unittest.cc | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/extensions/browser/runtime_data_unittest.cc b/extensions/browser/runtime_data_unittest.cc index 451308c..bec1e13 100644 --- a/extensions/browser/runtime_data_unittest.cc +++ b/extensions/browser/runtime_data_unittest.cc @@ -53,9 +53,9 @@ TEST_F(RuntimeDataTest, IsBackgroundPageReady) { EXPECT_FALSE(runtime_data_.IsBackgroundPageReady(with_background.get())); // The flag can be toggled. - runtime_data_.SetBackgroundPageReady(with_background.get(), true); + runtime_data_.SetBackgroundPageReady(with_background->id(), true); EXPECT_TRUE(runtime_data_.IsBackgroundPageReady(with_background.get())); - runtime_data_.SetBackgroundPageReady(with_background.get(), false); + runtime_data_.SetBackgroundPageReady(with_background->id(), false); EXPECT_FALSE(runtime_data_.IsBackgroundPageReady(with_background.get())); } @@ -63,37 +63,41 @@ TEST_F(RuntimeDataTest, IsBeingUpgraded) { scoped_refptr<Extension> extension = test_util::CreateEmptyExtension(); // An extension is not being upgraded until the flag is set. - EXPECT_FALSE(runtime_data_.IsBeingUpgraded(extension.get())); + EXPECT_FALSE(runtime_data_.IsBeingUpgraded(extension->id())); // The flag can be toggled. - runtime_data_.SetBeingUpgraded(extension.get(), true); - EXPECT_TRUE(runtime_data_.IsBeingUpgraded(extension.get())); - runtime_data_.SetBeingUpgraded(extension.get(), false); - EXPECT_FALSE(runtime_data_.IsBeingUpgraded(extension.get())); + runtime_data_.SetBeingUpgraded(extension->id(), true); + EXPECT_TRUE(runtime_data_.IsBeingUpgraded(extension->id())); + runtime_data_.SetBeingUpgraded(extension->id(), false); + EXPECT_FALSE(runtime_data_.IsBeingUpgraded(extension->id())); } TEST_F(RuntimeDataTest, HasUsedWebRequest) { scoped_refptr<Extension> extension = test_util::CreateEmptyExtension(); // An extension has not used web request until the flag is set. - EXPECT_FALSE(runtime_data_.HasUsedWebRequest(extension.get())); + EXPECT_FALSE(runtime_data_.HasUsedWebRequest(extension->id())); // The flag can be toggled. - runtime_data_.SetHasUsedWebRequest(extension.get(), true); - EXPECT_TRUE(runtime_data_.HasUsedWebRequest(extension.get())); - runtime_data_.SetHasUsedWebRequest(extension.get(), false); - EXPECT_FALSE(runtime_data_.HasUsedWebRequest(extension.get())); + runtime_data_.SetHasUsedWebRequest(extension->id(), true); + EXPECT_TRUE(runtime_data_.HasUsedWebRequest(extension->id())); + runtime_data_.SetHasUsedWebRequest(extension->id(), false); + EXPECT_FALSE(runtime_data_.HasUsedWebRequest(extension->id())); } -// Unloading an extension stops tracking it. +// Unloading an extension erases any data that shouldn't explicitly be kept +// across loads. TEST_F(RuntimeDataTest, OnExtensionUnloaded) { scoped_refptr<Extension> extension = CreateExtensionWithBackgroundPage(); - runtime_data_.SetBackgroundPageReady(extension.get(), true); - ASSERT_TRUE(runtime_data_.HasExtensionForTesting(extension.get())); + runtime_data_.SetBackgroundPageReady(extension->id(), true); + ASSERT_TRUE(runtime_data_.HasExtensionForTesting(extension->id())); + runtime_data_.SetBeingUpgraded(extension->id(), true); runtime_data_.OnExtensionUnloaded( NULL, extension.get(), UnloadedExtensionInfo::REASON_DISABLE); - EXPECT_FALSE(runtime_data_.HasExtensionForTesting(extension.get())); + EXPECT_TRUE(runtime_data_.HasExtensionForTesting(extension->id())); + EXPECT_FALSE(runtime_data_.IsBackgroundPageReady(extension.get())); + EXPECT_TRUE(runtime_data_.IsBeingUpgraded(extension->id())); } } // namespace |