OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "chrome/browser/nacl_host/pnacl_file_host.h" | |
6 | |
7 #include "base/basictypes.h" | |
8 #include "base/file_path.h" | |
9 #include "base/path_service.h" | |
10 #include "chrome/common/chrome_paths.h" | |
11 | |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | |
14 using pnacl_file_host::PnaclCanOpenFile; | |
15 | |
16 namespace { | |
17 | |
18 class PnaclFileHostTest : public ::testing::Test { | |
brettw
2012/07/23 18:09:02
Since this class doesn't do anything you can remov
jvoung (off chromium)
2012/07/23 19:59:04
Done.
| |
19 public: | |
20 PnaclFileHostTest() { | |
21 } | |
22 virtual ~PnaclFileHostTest() { | |
23 } | |
24 private: | |
25 DISALLOW_COPY_AND_ASSIGN(PnaclFileHostTest); | |
26 }; | |
27 | |
28 } // namespace | |
29 | |
30 // Try to pass a few funny filenames with a dummy pnacl directory set. | |
31 TEST_F(PnaclFileHostTest, TestFilenamesWithPnaclPath) { | |
32 FilePath kDummyPnaclPath(FILE_PATH_LITERAL("dummy_pnacl_path")); | |
33 ASSERT_TRUE(PathService::Override(chrome::DIR_PNACL_COMPONENT, | |
34 kDummyPnaclPath)); | |
35 ASSERT_TRUE(PathService::Get(chrome::DIR_PNACL_COMPONENT, | |
36 &kDummyPnaclPath)); | |
37 FilePath out_path; | |
38 EXPECT_TRUE(PnaclCanOpenFile("manifest.json", &out_path)); | |
39 FilePath expected_path = kDummyPnaclPath.Append( | |
40 FILE_PATH_LITERAL("manifest.json")); | |
41 EXPECT_EQ(out_path, expected_path); | |
42 | |
43 EXPECT_TRUE(PnaclCanOpenFile("x86-32/llc", &out_path)); | |
44 expected_path = kDummyPnaclPath.Append(FILE_PATH_LITERAL("x86-32/llc")); | |
45 EXPECT_EQ(out_path, expected_path); | |
46 | |
47 EXPECT_FALSE(PnaclCanOpenFile("", &out_path)); | |
48 EXPECT_FALSE(PnaclCanOpenFile(".", &out_path)); | |
49 EXPECT_FALSE(PnaclCanOpenFile("..", &out_path)); | |
50 #if defined(OS_WIN) | |
51 EXPECT_FALSE(PnaclCanOpenFile("..\\llc", &out_path)); | |
52 EXPECT_FALSE(PnaclCanOpenFile("%SystemRoot%", &out_path)); | |
53 EXPECT_FALSE(PnaclCanOpenFile("%SystemRoot%\\explorer.exe", &out_path)); | |
54 #else | |
55 EXPECT_FALSE(PnaclCanOpenFile("../llc", &out_path)); | |
56 EXPECT_FALSE(PnaclCanOpenFile("/bin/sh", &out_path)); | |
57 EXPECT_FALSE(PnaclCanOpenFile("$HOME", &out_path)); | |
58 EXPECT_FALSE(PnaclCanOpenFile("$HOME/.bashrc", &out_path)); | |
59 #endif | |
60 | |
61 const char non_ascii[] = "\xff\xfe"; | |
62 EXPECT_FALSE(PnaclCanOpenFile(non_ascii, &out_path)); | |
63 } | |
OLD | NEW |