Remove keyboard_ui.css and manifest_keyboard.json
[chromium-blink-merge.git] / chrome / browser / extensions / chrome_component_extension_resource_manager_unittest.cc
blob729b1ecd34b772f8ab4bc3b47aa0b27f1e6d47a1
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.
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"
19 #if defined(OS_CHROMEOS)
20 #include "ui/file_manager/grit/file_manager_resources.h"
21 #endif
23 namespace extensions {
25 typedef testing::Test ChromeComponentExtensionResourceManagerTest;
27 // Tests IsComponentExtensionResource function.
28 TEST_F(ChromeComponentExtensionResourceManagerTest,
29 IsComponentExtensionResource) {
30 const ComponentExtensionResourceManager* resource_manager =
31 ExtensionsBrowserClient::Get()->GetComponentExtensionResourceManager();
32 ASSERT_TRUE(resource_manager);
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");
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));
43 ASSERT_TRUE(manifest.get()) << error;
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");
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());
59 // Load one of the icons.
60 ExtensionResource resource =
61 IconsInfo::GetIconResource(extension.get(),
62 extension_misc::EXTENSION_ICON_BITTY,
63 ExtensionIconSet::MATCH_EXACTLY);
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
74 } // namespace extensions