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
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/extension_file_util.h"
9 #include "base/path_service.h"
10 #include "chrome/common/chrome_paths.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/common/file_util.h"
13 #include "extensions/common/manifest.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 namespace extensions
{
18 typedef testing::Test ExtensionFileUtilTest
;
20 // Test that a browser action extension returns a path to an icon.
21 TEST_F(ExtensionFileUtilTest
, GetBrowserImagePaths
) {
22 base::FilePath install_dir
;
23 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA
, &install_dir
));
24 install_dir
= install_dir
.AppendASCII("extensions")
25 .AppendASCII("api_test")
26 .AppendASCII("browser_action")
27 .AppendASCII("basics");
30 scoped_refptr
<Extension
> extension(file_util::LoadExtension(
31 install_dir
, Manifest::UNPACKED
, Extension::NO_FLAGS
, &error
));
32 ASSERT_TRUE(extension
.get());
34 // The extension contains one icon.
35 std::set
<base::FilePath
> paths
=
36 extension_file_util::GetBrowserImagePaths(extension
.get());
37 ASSERT_EQ(1u, paths
.size());
38 EXPECT_EQ("icon.png", paths
.begin()->BaseName().AsUTF8Unsafe());
41 } // namespace extensions