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"
7 #include "extensions/common/manifest_constants.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/gmock/include/gmock/gmock.h"
11 using extensions::Extension
;
13 namespace errors
= extensions::manifest_errors
;
15 TEST_F(ChromeManifestTest
, ManifestVersionError
) {
16 scoped_ptr
<base::DictionaryValue
> manifest1(new base::DictionaryValue());
17 manifest1
->SetString("name", "Miles");
18 manifest1
->SetString("version", "0.55");
20 scoped_ptr
<base::DictionaryValue
> manifest2(manifest1
->DeepCopy());
21 manifest2
->SetInteger("manifest_version", 1);
23 scoped_ptr
<base::DictionaryValue
> manifest3(manifest1
->DeepCopy());
24 manifest3
->SetInteger("manifest_version", 2);
27 const char* test_name
;
28 bool require_modern_manifest_version
;
29 base::DictionaryValue
* manifest
;
32 { "require_modern_with_default", true, manifest1
.get(), true },
33 { "require_modern_with_v1", true, manifest2
.get(), true },
34 { "require_modern_with_v2", true, manifest3
.get(), false },
35 { "dont_require_modern_with_default", false, manifest1
.get(), false },
36 { "dont_require_modern_with_v1", false, manifest2
.get(), false },
37 { "dont_require_modern_with_v2", false, manifest3
.get(), false },
40 for (size_t i
= 0; i
< arraysize(test_data
); ++i
) {
41 int create_flags
= Extension::NO_FLAGS
;
42 if (test_data
[i
].require_modern_manifest_version
)
43 create_flags
|= Extension::REQUIRE_MODERN_MANIFEST_VERSION
;
44 if (test_data
[i
].expect_error
) {
46 ManifestData(test_data
[i
].manifest
,
47 test_data
[i
].test_name
),
48 errors::kInvalidManifestVersionOld
,
49 extensions::Manifest::UNPACKED
,
52 LoadAndExpectSuccess(ManifestData(test_data
[i
].manifest
,
53 test_data
[i
].test_name
),
54 extensions::Manifest::UNPACKED
,