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" | 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" | 8 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" |
9 #include "chrome/common/extensions/extension_manifest_constants.h" | 9 #include "chrome/common/extensions/extension_manifest_constants.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 { | 31 { |
32 base::DictionaryValue ext_manifest; | 32 base::DictionaryValue ext_manifest; |
33 // Lack of "app" section representa an extension. So the base manifest | 33 // Lack of "app" section representa an extension. So the base manifest |
34 // itself represents an extension. | 34 // itself represents an extension. |
35 ext_manifest.MergeDictionary(&base_manifest); | 35 ext_manifest.MergeDictionary(&base_manifest); |
36 | 36 |
37 Manifest manifest(&ext_manifest, "test"); | 37 Manifest manifest(&ext_manifest, "test"); |
38 scoped_refptr<extensions::Extension> extension = | 38 scoped_refptr<extensions::Extension> extension = |
39 LoadAndExpectSuccess(manifest); | 39 LoadAndExpectSuccess(manifest); |
40 EXPECT_TRUE(extension->install_warnings().empty()); | 40 EXPECT_TRUE(extension->install_warnings().empty()); |
41 EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension).client_id); | 41 EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension.get()).client_id); |
42 EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension).scopes.size()); | 42 EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension.get()).scopes.size()); |
43 EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension).scopes[0]); | 43 EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension.get()).scopes[0]); |
44 EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension).scopes[1]); | 44 EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension.get()).scopes[1]); |
45 } | 45 } |
46 | 46 |
47 // OAuth2 section should be parsed for a packaged app. | 47 // OAuth2 section should be parsed for a packaged app. |
48 { | 48 { |
49 base::DictionaryValue app_manifest; | 49 base::DictionaryValue app_manifest; |
50 app_manifest.SetString(keys::kLaunchLocalPath, "launch.html"); | 50 app_manifest.SetString(keys::kLaunchLocalPath, "launch.html"); |
51 app_manifest.MergeDictionary(&base_manifest); | 51 app_manifest.MergeDictionary(&base_manifest); |
52 | 52 |
53 Manifest manifest(&app_manifest, "test"); | 53 Manifest manifest(&app_manifest, "test"); |
54 scoped_refptr<extensions::Extension> extension = | 54 scoped_refptr<extensions::Extension> extension = |
55 LoadAndExpectSuccess(manifest); | 55 LoadAndExpectSuccess(manifest); |
56 EXPECT_TRUE(extension->install_warnings().empty()); | 56 EXPECT_TRUE(extension->install_warnings().empty()); |
57 EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension).client_id); | 57 EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension.get()).client_id); |
58 EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension).scopes.size()); | 58 EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension.get()).scopes.size()); |
59 EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension).scopes[0]); | 59 EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension.get()).scopes[0]); |
60 EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension).scopes[1]); | 60 EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension.get()).scopes[1]); |
61 } | 61 } |
62 | 62 |
63 // OAuth2 section should NOT be parsed for a hosted app. | 63 // OAuth2 section should NOT be parsed for a hosted app. |
64 { | 64 { |
65 base::DictionaryValue app_manifest; | 65 base::DictionaryValue app_manifest; |
66 app_manifest.SetString(keys::kLaunchWebURL, "http://www.google.com"); | 66 app_manifest.SetString(keys::kLaunchWebURL, "http://www.google.com"); |
67 app_manifest.MergeDictionary(&base_manifest); | 67 app_manifest.MergeDictionary(&base_manifest); |
68 | 68 |
69 Manifest manifest(&app_manifest, "test"); | 69 Manifest manifest(&app_manifest, "test"); |
70 scoped_refptr<extensions::Extension> extension = | 70 scoped_refptr<extensions::Extension> extension = |
71 LoadAndExpectSuccess(manifest); | 71 LoadAndExpectSuccess(manifest); |
72 EXPECT_EQ(1U, extension->install_warnings().size()); | 72 EXPECT_EQ(1U, extension->install_warnings().size()); |
73 const extensions::InstallWarning& warning = | 73 const extensions::InstallWarning& warning = |
74 extension->install_warnings()[0]; | 74 extension->install_warnings()[0]; |
75 EXPECT_EQ("'oauth2' is only allowed for extensions, legacy packaged apps " | 75 EXPECT_EQ("'oauth2' is only allowed for extensions, legacy packaged apps " |
76 "and packaged apps, and this is a hosted app.", | 76 "and packaged apps, and this is a hosted app.", |
77 warning.message); | 77 warning.message); |
78 EXPECT_EQ("", OAuth2Info::GetOAuth2Info(extension).client_id); | 78 EXPECT_EQ("", OAuth2Info::GetOAuth2Info(extension.get()).client_id); |
79 EXPECT_TRUE(OAuth2Info::GetOAuth2Info(extension).scopes.empty()); | 79 EXPECT_TRUE(OAuth2Info::GetOAuth2Info(extension.get()).scopes.empty()); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 } // namespace extensions | 83 } // namespace extensions |
OLD | NEW |