Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: chrome/browser/extensions/chrome_component_extension_resource_manager_unittest.cc

Issue 439023002: Move ImageLoaderTest to extensions_unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (image-loader) rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/files/file_path.h"
6 #include "base/path_service.h"
7 #include "chrome/common/chrome_paths.h"
8 #include "extensions/browser/component_extension_resource_manager.h"
9 #include "extensions/browser/extensions_browser_client.h"
10 #include "extensions/common/constants.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/common/extension_icon_set.h"
13 #include "extensions/common/extension_resource.h"
14 #include "extensions/common/file_util.h"
15 #include "extensions/common/manifest.h"
16 #include "extensions/common/manifest_handlers/icons_handler.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18
19 #if defined(OS_CHROMEOS)
20 #include "ui/file_manager/grit/file_manager_resources.h"
21 #endif
22
23 namespace extensions {
24
25 typedef testing::Test ChromeComponentExtensionResourceManagerTest;
26
27 // Tests IsComponentExtensionResource function.
28 TEST_F(ChromeComponentExtensionResourceManagerTest,
29 IsComponentExtensionResource) {
30 ComponentExtensionResourceManager* resource_manager =
31 ExtensionsBrowserClient::Get()->GetComponentExtensionResourceManager();
32 ASSERT_TRUE(resource_manager);
33
34 // Get the extension test data path.
35 base::FilePath test_path;
36 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_path));
37 test_path = test_path.AppendASCII("extensions").AppendASCII("file_manager");
38
39 // Load the manifest data.
40 std::string error;
41 scoped_ptr<base::DictionaryValue> manifest(file_util::LoadManifest(
42 test_path, FILE_PATH_LITERAL("app.json"), &error));
Yoyo Zhou 2014/08/04 21:15:01 If this isn't called manifest.json, I will wonder
James Cook 2014/08/04 21:24:47 OK. This is existing test data in chrome/test/data
43 ASSERT_TRUE(manifest.get()) << error;
44
45 // Build a path inside Chrome's resources directory where a component
46 // extension might be installed.
47 base::FilePath resources_path;
48 ASSERT_TRUE(PathService::Get(chrome::DIR_RESOURCES, &resources_path));
49 resources_path = resources_path.AppendASCII("file_manager");
50
51 // Create a simulated component extension.
52 scoped_refptr<Extension> extension = Extension::Create(resources_path,
53 Manifest::COMPONENT,
54 *manifest,
55 Extension::NO_FLAGS,
56 &error);
57 ASSERT_TRUE(extension.get());
58
59 // Load one of the icons.
60 ExtensionResource resource =
61 IconsInfo::GetIconResource(extension.get(),
62 extension_misc::EXTENSION_ICON_BITTY,
63 ExtensionIconSet::MATCH_EXACTLY);
64
65 #if defined(OS_CHROMEOS)
66 // The resource is a component resource.
67 int resource_id = 0;
68 ASSERT_TRUE(resource_manager->IsComponentExtensionResource(
69 extension->path(), resource.relative_path(), &resource_id));
70 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id);
71 #endif
72 }
73
74 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698