| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/json/json_file_value_serializer.h" | 6 #include "base/json/json_file_value_serializer.h" |
| 7 #include "base/memory/linked_ptr.h" | 7 #include "base/memory/linked_ptr.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/extensions/csp_handler.h" | 9 #include "chrome/common/extensions/csp_handler.h" |
| 10 #include "chrome/common/extensions/extension_manifest_constants.h" | 10 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 11 #include "chrome/common/extensions/incognito_handler.h" | 11 #include "chrome/common/extensions/incognito_handler.h" |
| 12 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" | 12 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" |
| 13 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 13 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 14 #include "extensions/common/error_utils.h" |
| 14 #include "extensions/common/switches.h" | 15 #include "extensions/common/switches.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 namespace errors = extension_manifest_errors; | 18 namespace errors = extension_manifest_errors; |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 | 21 |
| 21 class PlatformAppsManifestTest : public ExtensionManifestTest { | 22 class PlatformAppsManifestTest : public ExtensionManifestTest { |
| 22 }; | 23 }; |
| 23 | 24 |
| 24 TEST_F(PlatformAppsManifestTest, PlatformApps) { | 25 TEST_F(PlatformAppsManifestTest, PlatformApps) { |
| 25 scoped_refptr<Extension> extension = | 26 scoped_refptr<Extension> extension = |
| 26 LoadAndExpectSuccess("init_valid_platform_app.json"); | 27 LoadAndExpectSuccess("init_valid_platform_app.json"); |
| 27 EXPECT_TRUE(AppIsolationInfo::HasIsolatedStorage(extension.get())); | 28 EXPECT_TRUE(AppIsolationInfo::HasIsolatedStorage(extension.get())); |
| 28 EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension.get())); | 29 EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension.get())); |
| 29 | 30 |
| 30 extension = | 31 extension = |
| 31 LoadAndExpectSuccess("init_valid_platform_app_no_manifest_version.json"); | 32 LoadAndExpectSuccess("init_valid_platform_app_no_manifest_version.json"); |
| 32 EXPECT_EQ(2, extension->manifest_version()); | 33 EXPECT_EQ(2, extension->manifest_version()); |
| 33 | 34 |
| 34 extension = LoadAndExpectSuccess("incognito_valid_platform_app.json"); | 35 extension = LoadAndExpectSuccess("incognito_valid_platform_app.json"); |
| 35 EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension.get())); | 36 EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension.get())); |
| 36 | 37 |
| 37 Testcase error_testcases[] = { | 38 Testcase error_testcases[] = { |
| 38 Testcase("init_invalid_platform_app_2.json", | 39 Testcase("init_invalid_platform_app_2.json", |
| 39 errors::kBackgroundRequiredForPlatformApps), | 40 errors::kBackgroundRequiredForPlatformApps), |
| 40 Testcase("init_invalid_platform_app_3.json", | 41 Testcase("init_invalid_platform_app_3.json", |
| 41 errors::kPlatformAppNeedsManifestVersion2), | 42 ErrorUtils::FormatErrorMessage( |
| 43 errors::kInvalidManifestVersionOld, "2", "apps")), |
| 42 }; | 44 }; |
| 43 RunTestcases(error_testcases, arraysize(error_testcases), EXPECT_TYPE_ERROR); | 45 RunTestcases(error_testcases, arraysize(error_testcases), EXPECT_TYPE_ERROR); |
| 44 | 46 |
| 45 Testcase warning_testcases[] = { | 47 Testcase warning_testcases[] = { |
| 46 Testcase( | 48 Testcase( |
| 47 "init_invalid_platform_app_1.json", | 49 "init_invalid_platform_app_1.json", |
| 48 "'app.launch' is only allowed for hosted apps and legacy packaged " | 50 "'app.launch' is only allowed for hosted apps and legacy packaged " |
| 49 "apps, and this is a packaged app."), | 51 "apps, and this is a packaged app."), |
| 50 Testcase( | 52 Testcase( |
| 51 "init_invalid_platform_app_4.json", | 53 "init_invalid_platform_app_4.json", |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 138 |
| 137 // Now try again with the experimental flag set. | 139 // Now try again with the experimental flag set. |
| 138 CommandLine::ForCurrentProcess()->AppendSwitch( | 140 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 139 switches::kEnableExperimentalExtensionApis); | 141 switches::kEnableExperimentalExtensionApis); |
| 140 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 142 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
| 141 LoadAndExpectSuccess(Manifest(manifests[i].get(), "")); | 143 LoadAndExpectSuccess(Manifest(manifests[i].get(), "")); |
| 142 } | 144 } |
| 143 } | 145 } |
| 144 | 146 |
| 145 } // namespace extensions | 147 } // namespace extensions |
| OLD | NEW |