OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/extensions/background_info.h" | |
6 #include "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
7 #include "chrome/common/extensions/extension_manifest_constants.h" | 6 #include "chrome/common/extensions/extension_manifest_constants.h" |
8 #include "chrome/common/extensions/manifest_handlers/offline_enabled_info.h" | 7 #include "chrome/common/extensions/manifest_handlers/offline_enabled_info.h" |
9 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 8 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
11 | 10 |
12 namespace errors = extension_manifest_errors; | 11 namespace errors = extension_manifest_errors; |
13 | 12 |
14 namespace extensions { | 13 namespace extensions { |
15 | 14 |
16 class ExtensionManifestOfflineEnabledTest : public ExtensionManifestTest { | 15 class ExtensionManifestOfflineEnabledTest : public ExtensionManifestTest { |
17 virtual void SetUp() OVERRIDE { | |
18 ExtensionManifestTest::SetUp(); | |
19 (new OfflineEnabledHandler)->Register(); | |
20 (new BackgroundManifestHandler)->Register(); | |
21 } | |
22 }; | 16 }; |
23 | 17 |
24 TEST_F(ExtensionManifestOfflineEnabledTest, OfflineEnabled) { | 18 TEST_F(ExtensionManifestOfflineEnabledTest, OfflineEnabled) { |
25 LoadAndExpectError("offline_enabled_invalid.json", | 19 LoadAndExpectError("offline_enabled_invalid.json", |
26 errors::kInvalidOfflineEnabled); | 20 errors::kInvalidOfflineEnabled); |
27 scoped_refptr<Extension> extension_0( | 21 scoped_refptr<Extension> extension_0( |
28 LoadAndExpectSuccess("offline_enabled_extension.json")); | 22 LoadAndExpectSuccess("offline_enabled_extension.json")); |
29 EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_0)); | 23 EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_0)); |
30 scoped_refptr<Extension> extension_1( | 24 scoped_refptr<Extension> extension_1( |
31 LoadAndExpectSuccess("offline_enabled_packaged_app.json")); | 25 LoadAndExpectSuccess("offline_enabled_packaged_app.json")); |
32 EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_1)); | 26 EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_1)); |
33 scoped_refptr<Extension> extension_2( | 27 scoped_refptr<Extension> extension_2( |
34 LoadAndExpectSuccess("offline_disabled_packaged_app.json")); | 28 LoadAndExpectSuccess("offline_disabled_packaged_app.json")); |
35 EXPECT_FALSE(OfflineEnabledInfo::IsOfflineEnabled(extension_2)); | 29 EXPECT_FALSE(OfflineEnabledInfo::IsOfflineEnabled(extension_2)); |
36 scoped_refptr<Extension> extension_3( | 30 scoped_refptr<Extension> extension_3( |
37 LoadAndExpectSuccess("offline_default_packaged_app.json")); | 31 LoadAndExpectSuccess("offline_default_packaged_app.json")); |
38 EXPECT_FALSE(OfflineEnabledInfo::IsOfflineEnabled(extension_3)); | 32 EXPECT_FALSE(OfflineEnabledInfo::IsOfflineEnabled(extension_3)); |
39 scoped_refptr<Extension> extension_4( | 33 scoped_refptr<Extension> extension_4( |
40 LoadAndExpectSuccess("offline_enabled_hosted_app.json")); | 34 LoadAndExpectSuccess("offline_enabled_hosted_app.json")); |
41 EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_4)); | 35 EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_4)); |
42 scoped_refptr<Extension> extension_5( | 36 scoped_refptr<Extension> extension_5( |
43 LoadAndExpectSuccess("offline_default_platform_app.json")); | 37 LoadAndExpectSuccess("offline_default_platform_app.json")); |
44 EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_5)); | 38 EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_5)); |
45 } | 39 } |
46 | 40 |
47 } // namespace extensions | 41 } // namespace extensions |
OLD | NEW |