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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 7 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
8 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 8 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 typedef ExtensionManifestTest ValidAppManifestTest; | 11 typedef ExtensionManifestTest ValidAppManifestTest; |
12 | 12 |
13 TEST_F(ValidAppManifestTest, ValidApp) { | 13 TEST_F(ValidAppManifestTest, ValidApp) { |
14 scoped_refptr<extensions::Extension> extension( | 14 scoped_refptr<extensions::Extension> extension( |
15 LoadAndExpectSuccess("valid_app.json")); | 15 LoadAndExpectSuccess("valid_app.json")); |
16 extensions::URLPatternSet expected_patterns; | 16 extensions::URLPatternSet expected_patterns; |
17 AddPattern(&expected_patterns, "http://www.google.com/mail/*"); | 17 AddPattern(&expected_patterns, "http://www.google.com/mail/*"); |
18 AddPattern(&expected_patterns, "http://www.google.com/foobar/*"); | 18 AddPattern(&expected_patterns, "http://www.google.com/foobar/*"); |
19 EXPECT_EQ(expected_patterns, extension->web_extent()); | 19 EXPECT_EQ(expected_patterns, extension->web_extent()); |
20 EXPECT_EQ(extensions::LAUNCH_TAB, | 20 EXPECT_EQ(extensions::LAUNCH_CONTAINER_TAB, |
21 extensions::AppLaunchInfo::GetLaunchContainer(extension.get())); | 21 extensions::AppLaunchInfo::GetLaunchContainer(extension.get())); |
22 EXPECT_EQ(GURL("http://www.google.com/mail/"), | 22 EXPECT_EQ(GURL("http://www.google.com/mail/"), |
23 extensions::AppLaunchInfo::GetLaunchWebURL(extension.get())); | 23 extensions::AppLaunchInfo::GetLaunchWebURL(extension.get())); |
24 } | 24 } |
25 | 25 |
26 TEST_F(ValidAppManifestTest, AllowUnrecognizedPermissions) { | 26 TEST_F(ValidAppManifestTest, AllowUnrecognizedPermissions) { |
27 std::string error; | 27 std::string error; |
28 scoped_ptr<base::DictionaryValue> manifest( | 28 scoped_ptr<base::DictionaryValue> manifest( |
29 LoadManifest("valid_app.json", &error)); | 29 LoadManifest("valid_app.json", &error)); |
30 base::ListValue* permissions = NULL; | 30 base::ListValue* permissions = NULL; |
31 ASSERT_TRUE(manifest->GetList("permissions", &permissions)); | 31 ASSERT_TRUE(manifest->GetList("permissions", &permissions)); |
32 permissions->Append(new StringValue("not-a-valid-permission")); | 32 permissions->Append(new StringValue("not-a-valid-permission")); |
33 LoadAndExpectSuccess(Manifest(manifest.get(), "")); | 33 LoadAndExpectSuccess(Manifest(manifest.get(), "")); |
34 } | 34 } |
OLD | NEW |