OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // These tests make sure SettingsOverridePermission values are set correctly. | 5 // These tests make sure SettingsOverridePermission values are set correctly. |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include <stdint.h> |
| 8 |
8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "build/build_config.h" |
10 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" | 12 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" |
11 #include "extensions/common/manifest_constants.h" | 13 #include "extensions/common/manifest_constants.h" |
12 #include "extensions/common/permissions/permission_message_test_util.h" | 14 #include "extensions/common/permissions/permission_message_test_util.h" |
13 #include "extensions/common/permissions/permission_set.h" | 15 #include "extensions/common/permissions/permission_set.h" |
14 #include "extensions/common/permissions/permissions_data.h" | 16 #include "extensions/common/permissions/permissions_data.h" |
15 #include "extensions/common/permissions/settings_override_permission.h" | 17 #include "extensions/common/permissions/settings_override_permission.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
17 | 19 |
18 namespace extensions { | 20 namespace extensions { |
19 | 21 |
20 namespace { | 22 namespace { |
21 | 23 |
22 class SettingsOverridePermissionTest : public ChromeManifestTest { | 24 class SettingsOverridePermissionTest : public ChromeManifestTest { |
23 protected: | 25 protected: |
24 enum Flags { | 26 enum Flags { |
25 kHomepage = 1, | 27 kHomepage = 1, |
26 kStartupPages = 1 << 1, | 28 kStartupPages = 1 << 1, |
27 kSearchProvider = 1 << 2, | 29 kSearchProvider = 1 << 2, |
28 }; | 30 }; |
29 | 31 |
30 scoped_refptr<Extension> GetPermissionSet(uint32 flags) { | 32 scoped_refptr<Extension> GetPermissionSet(uint32_t flags) { |
31 base::DictionaryValue ext_manifest; | 33 base::DictionaryValue ext_manifest; |
32 ext_manifest.SetString(manifest_keys::kName, "test"); | 34 ext_manifest.SetString(manifest_keys::kName, "test"); |
33 ext_manifest.SetString(manifest_keys::kVersion, "0.1"); | 35 ext_manifest.SetString(manifest_keys::kVersion, "0.1"); |
34 ext_manifest.SetInteger(manifest_keys::kManifestVersion, 2); | 36 ext_manifest.SetInteger(manifest_keys::kManifestVersion, 2); |
35 | 37 |
36 scoped_ptr<base::DictionaryValue> settings_override( | 38 scoped_ptr<base::DictionaryValue> settings_override( |
37 new base::DictionaryValue); | 39 new base::DictionaryValue); |
38 if (flags & kHomepage) | 40 if (flags & kHomepage) |
39 settings_override->SetString("homepage", "http://www.google.com"); | 41 settings_override->SetString("homepage", "http://www.google.com"); |
40 if (flags & kStartupPages) { | 42 if (flags & kStartupPages) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kHomepage)); | 146 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kHomepage)); |
145 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kSearchProvider)); | 147 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kSearchProvider)); |
146 #endif | 148 #endif |
147 | 149 |
148 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kStartupPages)); | 150 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kStartupPages)); |
149 } | 151 } |
150 | 152 |
151 } // namespace | 153 } // namespace |
152 | 154 |
153 } // namespace extensions | 155 } // namespace extensions |
OLD | NEW |