| 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 // TODO(rickcam): Bug 73183: Add unit tests for image loading | 5 // TODO(rickcam): Bug 73183: Add unit tests for image loading |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "chrome/browser/background/background_application_list_model.h" | 10 #include "chrome/browser/background/background_application_list_model.h" |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_service_unittest.h" | 18 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 19 #include "chrome/browser/extensions/extension_system.h" | 19 #include "chrome/browser/extensions/extension_system.h" |
| 20 #include "chrome/browser/extensions/permissions_updater.h" | 20 #include "chrome/browser/extensions/permissions_updater.h" |
| 21 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
| 22 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 23 #include "chrome/common/extensions/permissions/api_permission.h" | 22 #include "chrome/common/extensions/permissions/api_permission.h" |
| 24 #include "chrome/common/extensions/permissions/permission_set.h" | 23 #include "chrome/common/extensions/permissions/permission_set.h" |
| 25 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
| 26 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
| 27 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
| 27 #include "extensions/common/manifest_constants.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 29 |
| 30 // This value is used to seed the PRNG at the beginning of a sequence of | 30 // This value is used to seed the PRNG at the beginning of a sequence of |
| 31 // operations to produce a repeatable sequence. | 31 // operations to produce a repeatable sequence. |
| 32 #define RANDOM_SEED (0x33F7A7A7) | 32 #define RANDOM_SEED (0x33F7A7A7) |
| 33 | 33 |
| 34 using extensions::APIPermission; | 34 using extensions::APIPermission; |
| 35 using extensions::Extension; | 35 using extensions::Extension; |
| 36 | 36 |
| 37 // For ExtensionService interface when it requires a path that is not used. | 37 // For ExtensionService interface when it requires a path that is not used. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 55 profile_.get()); | 55 profile_.get()); |
| 56 } | 56 } |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // Returns a barebones test Extension object with the specified |name|. The | 59 // Returns a barebones test Extension object with the specified |name|. The |
| 60 // returned extension will include background permission iff | 60 // returned extension will include background permission iff |
| 61 // |background_permission| is true. | 61 // |background_permission| is true. |
| 62 static scoped_refptr<Extension> CreateExtension(const std::string& name, | 62 static scoped_refptr<Extension> CreateExtension(const std::string& name, |
| 63 bool background_permission) { | 63 bool background_permission) { |
| 64 DictionaryValue manifest; | 64 DictionaryValue manifest; |
| 65 manifest.SetString(extension_manifest_keys::kVersion, "1.0.0.0"); | 65 manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); |
| 66 manifest.SetString(extension_manifest_keys::kName, name); | 66 manifest.SetString(extensions::manifest_keys::kName, name); |
| 67 if (background_permission) { | 67 if (background_permission) { |
| 68 ListValue* permissions = new ListValue(); | 68 ListValue* permissions = new ListValue(); |
| 69 manifest.Set(extension_manifest_keys::kPermissions, permissions); | 69 manifest.Set(extensions::manifest_keys::kPermissions, permissions); |
| 70 permissions->Append(Value::CreateStringValue("background")); | 70 permissions->Append(Value::CreateStringValue("background")); |
| 71 } | 71 } |
| 72 std::string error; | 72 std::string error; |
| 73 scoped_refptr<Extension> extension = Extension::Create( | 73 scoped_refptr<Extension> extension = Extension::Create( |
| 74 bogus_file_path().AppendASCII(name), | 74 bogus_file_path().AppendASCII(name), |
| 75 extensions::Manifest::INVALID_LOCATION, | 75 extensions::Manifest::INVALID_LOCATION, |
| 76 manifest, | 76 manifest, |
| 77 Extension::NO_FLAGS, | 77 Extension::NO_FLAGS, |
| 78 &error); | 78 &error); |
| 79 // Cannot ASSERT_* here because that attempts an illegitimate return. | 79 // Cannot ASSERT_* here because that attempts an illegitimate return. |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 break; | 370 break; |
| 371 case 2: | 371 case 2: |
| 372 TogglePermission(service, &extensions, model.get(), &expected, &count); | 372 TogglePermission(service, &extensions, model.get(), &expected, &count); |
| 373 break; | 373 break; |
| 374 default: | 374 default: |
| 375 NOTREACHED(); | 375 NOTREACHED(); |
| 376 break; | 376 break; |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 } | 379 } |
| OLD | NEW |