| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 3012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3023 | 3023 |
| 3024 // Simulate an external_extensions.json file that contains seven invalid | 3024 // Simulate an external_extensions.json file that contains seven invalid |
| 3025 // extensions: | 3025 // extensions: |
| 3026 // - One that is missing the 'external_crx' key. | 3026 // - One that is missing the 'external_crx' key. |
| 3027 // - One that is missing the 'external_version' key. | 3027 // - One that is missing the 'external_version' key. |
| 3028 // - One that is specifying .. in the path. | 3028 // - One that is specifying .. in the path. |
| 3029 // - One that specifies both a file and update URL. | 3029 // - One that specifies both a file and update URL. |
| 3030 // - One that specifies no file or update URL. | 3030 // - One that specifies no file or update URL. |
| 3031 // - One that has an update URL that is not well formed. | 3031 // - One that has an update URL that is not well formed. |
| 3032 // - One that contains a malformed version. | 3032 // - One that contains a malformed version. |
| 3033 // - One that has an invalid id. |
| 3034 // - One that has a non-dictionary value. |
| 3033 // The final extension is valid, and we check that it is read to make sure | 3035 // The final extension is valid, and we check that it is read to make sure |
| 3034 // failures don't stop valid records from being read. | 3036 // failures don't stop valid records from being read. |
| 3035 json_data = | 3037 json_data = |
| 3036 "{" | 3038 "{" |
| 3037 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" | 3039 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" |
| 3038 " \"external_version\": \"1.0\"" | 3040 " \"external_version\": \"1.0\"" |
| 3039 " }," | 3041 " }," |
| 3040 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\": {" | 3042 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\": {" |
| 3041 " \"external_crx\": \"RandomExtension.crx\"" | 3043 " \"external_crx\": \"RandomExtension.crx\"" |
| 3042 " }," | 3044 " }," |
| 3043 " \"cccccccccccccccccccccccccccccccc\": {" | 3045 " \"cccccccccccccccccccccccccccccccc\": {" |
| 3044 " \"external_crx\": \"..\\\\foo\\\\RandomExtension2.crx\"," | 3046 " \"external_crx\": \"..\\\\foo\\\\RandomExtension2.crx\"," |
| 3045 " \"external_version\": \"2.0\"" | 3047 " \"external_version\": \"2.0\"" |
| 3046 " }," | 3048 " }," |
| 3047 " \"dddddddddddddddddddddddddddddddd\": {" | 3049 " \"dddddddddddddddddddddddddddddddd\": {" |
| 3048 " \"external_crx\": \"RandomExtension2.crx\"," | 3050 " \"external_crx\": \"RandomExtension2.crx\"," |
| 3049 " \"external_version\": \"2.0\"," | 3051 " \"external_version\": \"2.0\"," |
| 3050 " \"external_update_url\": \"http:\\\\foo.com/update\"" | 3052 " \"external_update_url\": \"http:\\\\foo.com/update\"" |
| 3051 " }," | 3053 " }," |
| 3052 " \"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\": {" | 3054 " \"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\": {" |
| 3053 " }," | 3055 " }," |
| 3054 " \"ffffffffffffffffffffffffffffffff\": {" | 3056 " \"ffffffffffffffffffffffffffffffff\": {" |
| 3055 " \"external_update_url\": \"This string is not a valid URL\"" | 3057 " \"external_update_url\": \"This string is not a valid URL\"" |
| 3056 " }," | 3058 " }," |
| 3057 " \"gggggggggggggggggggggggggggggggg\": {" | 3059 " \"gggggggggggggggggggggggggggggggg\": {" |
| 3058 " \"external_crx\": \"RandomExtension3.crx\"," | 3060 " \"external_crx\": \"RandomExtension3.crx\"," |
| 3059 " \"external_version\": \"This is not a valid version!\"" | 3061 " \"external_version\": \"This is not a valid version!\"" |
| 3060 " }," | 3062 " }," |
| 3061 " \"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\": {" | 3063 " \"This is not a valid id!\": {}," |
| 3064 " \"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\": true," |
| 3065 " \"pppppppppppppppppppppppppppppppp\": {" |
| 3062 " \"external_crx\": \"RandomValidExtension.crx\"," | 3066 " \"external_crx\": \"RandomValidExtension.crx\"," |
| 3063 " \"external_version\": \"1.0\"" | 3067 " \"external_version\": \"1.0\"" |
| 3064 " }" | 3068 " }" |
| 3065 "}"; | 3069 "}"; |
| 3066 EXPECT_EQ(1, visitor.Visit(json_data)); | 3070 EXPECT_EQ(1, visitor.Visit(json_data)); |
| 3067 } | 3071 } |
| 3068 | 3072 |
| 3069 // Test loading good extensions from the profile directory. | 3073 // Test loading good extensions from the profile directory. |
| 3070 TEST_F(ExtensionServiceTest, LoadAndRelocalizeExtensions) { | 3074 TEST_F(ExtensionServiceTest, LoadAndRelocalizeExtensions) { |
| 3071 // Initialize the test dir with a good Preferences/extensions. | 3075 // Initialize the test dir with a good Preferences/extensions. |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3281 // Component extensions shouldn't get recourded in the prefs. | 3285 // Component extensions shouldn't get recourded in the prefs. |
| 3282 ValidatePrefKeyCount(0); | 3286 ValidatePrefKeyCount(0); |
| 3283 | 3287 |
| 3284 // Reload all extensions, and make sure it comes back. | 3288 // Reload all extensions, and make sure it comes back. |
| 3285 std::string extension_id = service_->extensions()->at(0)->id(); | 3289 std::string extension_id = service_->extensions()->at(0)->id(); |
| 3286 loaded_.clear(); | 3290 loaded_.clear(); |
| 3287 service_->ReloadExtensions(); | 3291 service_->ReloadExtensions(); |
| 3288 ASSERT_EQ(1u, service_->extensions()->size()); | 3292 ASSERT_EQ(1u, service_->extensions()->size()); |
| 3289 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 3293 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
| 3290 } | 3294 } |
| OLD | NEW |