| Index: extensions/browser/runtime_data_unittest.cc
|
| diff --git a/extensions/browser/runtime_data_unittest.cc b/extensions/browser/runtime_data_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..84da665f994cf001dae73f4e72f18bc00af31b05
|
| --- /dev/null
|
| +++ b/extensions/browser/runtime_data_unittest.cc
|
| @@ -0,0 +1,90 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "extensions/browser/runtime_data.h"
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/memory/ref_counted.h"
|
| +#include "extensions/common/extension.h"
|
| +#include "extensions/common/extension_builder.h"
|
| +#include "extensions/common/value_builder.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace extensions {
|
| +namespace {
|
| +
|
| +typedef testing::Test RuntimeDataTest;
|
| +
|
| +// Creates a very simple extension.
|
| +scoped_refptr<Extension> CreateExtension() {
|
| + return ExtensionBuilder()
|
| + .SetManifest(
|
| + DictionaryBuilder().Set("name", "test").Set("version", "0.1"))
|
| + .SetID("id1")
|
| + .Build();
|
| +}
|
| +
|
| +// Creates a very simple extension with a background page.
|
| +scoped_refptr<Extension> CreateExtensionWithBackgroundPage() {
|
| + return ExtensionBuilder()
|
| + .SetManifest(
|
| + DictionaryBuilder()
|
| + .Set("name", "test")
|
| + .Set("version", "0.1")
|
| + .Set("background", DictionaryBuilder().Set("page", "bg.html")))
|
| + .SetID("id2")
|
| + .Build();
|
| +}
|
| +
|
| +TEST_F(RuntimeDataTest, IsBackgroundPageReady) {
|
| + RuntimeData runtime_data;
|
| +
|
| + // An extension without a background page is always considered ready.
|
| + scoped_refptr<Extension> no_background = CreateExtension();
|
| + EXPECT_TRUE(runtime_data.IsBackgroundPageReady(no_background));
|
| +
|
| + // An extension with a background page is not ready until the flag is set.
|
| + scoped_refptr<Extension> with_background =
|
| + CreateExtensionWithBackgroundPage();
|
| + EXPECT_FALSE(runtime_data.IsBackgroundPageReady(with_background));
|
| +
|
| + // The flag can be toggled.
|
| + runtime_data.SetBackgroundPageReady(with_background, true);
|
| + EXPECT_TRUE(runtime_data.IsBackgroundPageReady(with_background));
|
| + runtime_data.SetBackgroundPageReady(with_background, false);
|
| + EXPECT_FALSE(runtime_data.IsBackgroundPageReady(with_background));
|
| +}
|
| +
|
| +TEST_F(RuntimeDataTest, IsBeingUpgraded) {
|
| + RuntimeData runtime_data;
|
| + scoped_refptr<Extension> extension = CreateExtension();
|
| +
|
| + // An extension is not being upgraded until the flag is set.
|
| + EXPECT_FALSE(runtime_data.IsBeingUpgraded(extension));
|
| +
|
| + // The flag can be toggled.
|
| + runtime_data.SetBeingUpgraded(extension, true);
|
| + EXPECT_TRUE(runtime_data.IsBeingUpgraded(extension));
|
| + runtime_data.SetBeingUpgraded(extension, false);
|
| + EXPECT_FALSE(runtime_data.IsBeingUpgraded(extension));
|
| +}
|
| +
|
| +// TODO(mpcomplete): Remove. http://crbug.com/100411
|
| +TEST_F(RuntimeDataTest, HasUsedWebRequest) {
|
| + RuntimeData runtime_data;
|
| + scoped_refptr<Extension> extension = CreateExtension();
|
| +
|
| + // An extension has not used web request until the flag is set.
|
| + EXPECT_FALSE(runtime_data.HasUsedWebRequest(extension));
|
| +
|
| + // The flag can be toggled.
|
| + runtime_data.SetHasUsedWebRequest(extension, true);
|
| + EXPECT_TRUE(runtime_data.HasUsedWebRequest(extension));
|
| + runtime_data.SetHasUsedWebRequest(extension, false);
|
| + EXPECT_FALSE(runtime_data.HasUsedWebRequest(extension));
|
| +}
|
| +
|
| +} // namespace
|
| +} // namespace extensions
|
|
|