OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "chrome/common/extensions/features/feature_channel.h" | 7 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" |
8 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | |
9 #include "extensions/common/error_utils.h" | 8 #include "extensions/common/error_utils.h" |
10 #include "extensions/common/manifest_constants.h" | 9 #include "extensions/common/manifest_constants.h" |
11 #include "extensions/common/manifest_handlers/externally_connectable.h" | 10 #include "extensions/common/manifest_handlers/externally_connectable.h" |
12 #include "extensions/common/permissions/permissions_data.h" | 11 #include "extensions/common/permissions/permissions_data.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
15 | 14 |
16 using testing::ElementsAre; | 15 using testing::ElementsAre; |
17 | 16 |
18 namespace extensions { | 17 namespace extensions { |
19 | 18 |
20 namespace errors = externally_connectable_errors; | 19 namespace errors = externally_connectable_errors; |
21 | 20 |
22 class ExternallyConnectableTest : public ExtensionManifestTest { | 21 // TODO(jamescook): Convert from ChromeManifestTest to ManifestTest. |
| 22 class ExternallyConnectableTest : public ChromeManifestTest { |
23 public: | 23 public: |
24 ExternallyConnectableTest() : channel_(chrome::VersionInfo::CHANNEL_DEV) {} | 24 ExternallyConnectableTest() {} |
| 25 virtual ~ExternallyConnectableTest() {} |
25 | 26 |
26 protected: | 27 protected: |
27 ExternallyConnectableInfo* GetExternallyConnectableInfo( | 28 ExternallyConnectableInfo* GetExternallyConnectableInfo( |
28 scoped_refptr<Extension> extension) { | 29 scoped_refptr<Extension> extension) { |
29 return static_cast<ExternallyConnectableInfo*>( | 30 return static_cast<ExternallyConnectableInfo*>( |
30 extension->GetManifestData(manifest_keys::kExternallyConnectable)); | 31 extension->GetManifestData(manifest_keys::kExternallyConnectable)); |
31 } | 32 } |
32 | |
33 private: | |
34 ScopedCurrentChannel channel_; | |
35 }; | 33 }; |
36 | 34 |
37 TEST_F(ExternallyConnectableTest, IDsAndMatches) { | 35 TEST_F(ExternallyConnectableTest, IDsAndMatches) { |
38 scoped_refptr<Extension> extension = | 36 scoped_refptr<Extension> extension = |
39 LoadAndExpectSuccess("externally_connectable_ids_and_matches.json"); | 37 LoadAndExpectSuccess("externally_connectable_ids_and_matches.json"); |
40 ASSERT_TRUE(extension.get()); | 38 ASSERT_TRUE(extension.get()); |
41 | 39 |
42 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( | 40 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( |
43 APIPermission::kWebConnectable)); | 41 APIPermission::kWebConnectable)); |
44 | 42 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 EXPECT_TRUE(info->matches.MatchesURL(GURL("https://example.com"))); | 310 EXPECT_TRUE(info->matches.MatchesURL(GURL("https://example.com"))); |
313 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://build.chromium.org"))); | 311 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://build.chromium.org"))); |
314 } | 312 } |
315 | 313 |
316 TEST_F(ExternallyConnectableTest, WarningNothingSpecified) { | 314 TEST_F(ExternallyConnectableTest, WarningNothingSpecified) { |
317 LoadAndExpectWarning("externally_connectable_nothing_specified.json", | 315 LoadAndExpectWarning("externally_connectable_nothing_specified.json", |
318 errors::kErrorNothingSpecified); | 316 errors::kErrorNothingSpecified); |
319 } | 317 } |
320 | 318 |
321 } // namespace extensions | 319 } // namespace extensions |
OLD | NEW |