Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / common / extensions / manifest_tests / extension_manifests_requirements_unittest.cc
blob99c1a9dea8f39e7e18bfe6a73127fe148acfe61c
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
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
6 #include "extensions/common/error_utils.h"
7 #include "extensions/common/manifest_constants.h"
8 #include "extensions/common/manifest_handlers/requirements_info.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace extensions {
13 namespace errors = manifest_errors;
15 class RequirementsManifestTest : public ChromeManifestTest {
18 TEST_F(RequirementsManifestTest, RequirementsInvalid) {
19 Testcase testcases[] = {
20 Testcase("requirements_invalid_requirements.json",
21 errors::kInvalidRequirements),
22 Testcase("requirements_invalid_keys.json", errors::kInvalidRequirements),
23 Testcase("requirements_invalid_3d.json",
24 ErrorUtils::FormatErrorMessage(
25 errors::kInvalidRequirement, "3D")),
26 Testcase("requirements_invalid_3d_features.json",
27 ErrorUtils::FormatErrorMessage(
28 errors::kInvalidRequirement, "3D")),
29 Testcase("requirements_invalid_3d_features_value.json",
30 ErrorUtils::FormatErrorMessage(
31 errors::kInvalidRequirement, "3D")),
32 Testcase("requirements_invalid_3d_no_features.json",
33 ErrorUtils::FormatErrorMessage(
34 errors::kInvalidRequirement, "3D")),
35 Testcase("requirements_invalid_plugins.json",
36 ErrorUtils::FormatErrorMessage(
37 errors::kInvalidRequirement, "plugins")),
38 Testcase("requirements_invalid_plugins_key.json",
39 ErrorUtils::FormatErrorMessage(
40 errors::kInvalidRequirement, "plugins")),
41 Testcase("requirements_invalid_plugins_value.json",
42 ErrorUtils::FormatErrorMessage(
43 errors::kInvalidRequirement, "plugins"))
46 RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
49 TEST_F(RequirementsManifestTest, RequirementsValid) {
50 // Test the defaults.
51 scoped_refptr<Extension> extension(LoadAndExpectSuccess(
52 "requirements_valid_empty.json"));
53 ASSERT_TRUE(extension.get());
54 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false);
55 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, false);
57 // Test loading all the requirements.
58 extension = LoadAndExpectSuccess("requirements_valid_full.json");
59 ASSERT_TRUE(extension.get());
60 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, true);
61 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, true);
64 // When an npapi plugin is present, the default of the "npapi" requirement
65 // changes.
66 TEST_F(RequirementsManifestTest, RequirementsNpapiDefault) {
67 scoped_refptr<Extension> extension(LoadAndExpectSuccess(
68 "requirements_npapi_empty.json"));
69 ASSERT_TRUE(extension.get());
70 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false);
71 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, true);
73 extension = LoadAndExpectSuccess(
74 "requirements_npapi_empty_plugins_empty.json");
75 ASSERT_TRUE(extension.get());
76 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false);
77 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, false);
79 extension = LoadAndExpectSuccess("requirements_npapi.json");
80 ASSERT_TRUE(extension.get());
81 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false);
82 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, false);
84 extension = LoadAndExpectSuccess("requirements_npapi_plugins_empty.json");
85 ASSERT_TRUE(extension.get());
86 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false);
87 EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, true);
90 } // namespace extensions