summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_protocols_unittest.cc
blob: dee70a86307d0559fc07f4276c40591b56df0c53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_protocols.h"
#include "testing/gtest/include/gtest/gtest.h"

class ExtensionProtocolsTest : public testing::Test {
};

TEST(ExtensionProtocolsTest, GetPathForExtensionResource) {
#if defined(OS_WIN)
  FilePath extension_path(FILE_PATH_LITERAL("C:\\myextension"));
  EXPECT_EQ(std::wstring(L"C:\\myextension\\foo\\bar.gif"),
            GetPathForExtensionResource(extension_path, "/foo/bar.gif").value());
  EXPECT_EQ(std::wstring(L"C:\\myextension\\"),
            GetPathForExtensionResource(extension_path, "/").value());
  EXPECT_EQ(std::wstring(L"C:\\myextension\\c:\\foo.gif"),
            GetPathForExtensionResource(extension_path, "/c:/foo.gif").value());
  EXPECT_EQ(std::wstring(L""),
            GetPathForExtensionResource(extension_path, "/../foo.gif").value());
#else
  FilePath extension_path(FILE_PATH_LITERAL("/myextension"));
  EXPECT_EQ(std::wstring("/myextension/foo/bar.gif"),
            GetPathForExtensionResource(extension_path, "/foo/bar.gif").value());
  EXPECT_EQ(std::wstring("/myextension/"),
            GetPathForExtensionResource(extension_path, "/").value());
  EXPECT_EQ(std::wstring(""),
            GetPathForExtensionResource(extension_path, "/../foo.gif").value());
#endif


}