Chromium Code Reviews| 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 "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | |
| 6 | |
| 7 #include "base/values.h" | 5 #include "base/values.h" |
| 8 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "chrome/common/extensions/app_launch_manifest_handler.h" | |
| 8 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 9 #include "chrome/common/extensions/manifest_handler.h" | |
| 10 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 12 |
| 11 TEST_F(ExtensionManifestTest, ValidApp) { | 13 class ValidAppManifestTest : public ExtensionManifestTest { |
| 14 virtual void SetUp() OVERRIDE { | |
|
Devlin
2013/02/27 19:12:48
while a private: level is default with classes, we
Joe Thomas
2013/03/01 23:26:57
Done.
| |
| 15 ExtensionManifestTest::SetUp(); | |
| 16 std::vector<std::string> app_launch_keys( | |
| 17 extensions::AppLaunchManifestHandler::keys()); | |
| 18 linked_ptr<extensions::AppLaunchManifestHandler> app_launch_handler( | |
| 19 new extensions::AppLaunchManifestHandler); | |
| 20 for (size_t i = 0; i < app_launch_keys.size(); ++i) | |
|
Devlin
2013/02/27 19:12:48
Just out of curiosity, is there a reason we don't
Yoyo Zhou
2013/02/27 19:40:32
It's in the works and should land today:
https://c
| |
| 21 extensions::ManifestHandler::Register(app_launch_keys[i], | |
| 22 app_launch_handler); | |
| 23 } | |
| 24 }; | |
| 25 | |
| 26 TEST_F(ValidAppManifestTest, ValidApp) { | |
| 12 scoped_refptr<extensions::Extension> extension( | 27 scoped_refptr<extensions::Extension> extension( |
| 13 LoadAndExpectSuccess("valid_app.json")); | 28 LoadAndExpectSuccess("valid_app.json")); |
| 14 extensions::URLPatternSet expected_patterns; | 29 extensions::URLPatternSet expected_patterns; |
| 15 AddPattern(&expected_patterns, "http://www.google.com/mail/*"); | 30 AddPattern(&expected_patterns, "http://www.google.com/mail/*"); |
| 16 AddPattern(&expected_patterns, "http://www.google.com/foobar/*"); | 31 AddPattern(&expected_patterns, "http://www.google.com/foobar/*"); |
| 17 EXPECT_EQ(expected_patterns, extension->web_extent()); | 32 EXPECT_EQ(expected_patterns, extension->web_extent()); |
| 18 EXPECT_EQ(extension_misc::LAUNCH_TAB, extension->launch_container()); | 33 EXPECT_EQ(extension_misc::LAUNCH_TAB, |
| 19 EXPECT_EQ("http://www.google.com/mail/", extension->launch_web_url()); | 34 extensions::AppLaunchInfo::GetLaunchContainer(extension)); |
| 35 EXPECT_EQ("http://www.google.com/mail/", | |
| 36 extensions::AppLaunchInfo::GetLaunchWebUrl(extension)); | |
| 20 } | 37 } |
| 21 | 38 |
| 22 TEST_F(ExtensionManifestTest, AllowUnrecognizedPermissions) { | 39 TEST_F(ValidAppManifestTest, AllowUnrecognizedPermissions) { |
| 23 std::string error; | 40 std::string error; |
| 24 scoped_ptr<DictionaryValue> manifest(LoadManifest("valid_app.json", &error)); | 41 scoped_ptr<DictionaryValue> manifest(LoadManifest("valid_app.json", &error)); |
| 25 ListValue* permissions = NULL; | 42 ListValue* permissions = NULL; |
| 26 ASSERT_TRUE(manifest->GetList("permissions", &permissions)); | 43 ASSERT_TRUE(manifest->GetList("permissions", &permissions)); |
| 27 permissions->Append(new StringValue("not-a-valid-permission")); | 44 permissions->Append(new StringValue("not-a-valid-permission")); |
| 28 LoadAndExpectSuccess(Manifest(manifest.get(), "")); | 45 LoadAndExpectSuccess(Manifest(manifest.get(), "")); |
| 29 } | 46 } |
| OLD | NEW |