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

Side by Side Diff: chrome/browser/nacl_host/pnacl_file_host_unittest.cc

Issue 10662006: Add a NaCl-Private interface for opening files in DIR_PNACL_COMPONENT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: do not run test when disable_nacl=1 Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
(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 // Try to pass a few funny filenames with a dummy pnacl directory set.
17 TEST(PnaclFileHostTest, TestFilenamesWithPnaclPath) {
18 FilePath kDummyPnaclPath(FILE_PATH_LITERAL("dummy_pnacl_path"));
19 ASSERT_TRUE(PathService::Override(chrome::DIR_PNACL_COMPONENT,
20 kDummyPnaclPath));
21 ASSERT_TRUE(PathService::Get(chrome::DIR_PNACL_COMPONENT,
22 &kDummyPnaclPath));
23 FilePath out_path;
24 EXPECT_TRUE(PnaclCanOpenFile("manifest.json", &out_path));
25 FilePath expected_path = kDummyPnaclPath.Append(
26 FILE_PATH_LITERAL("manifest.json"));
27 EXPECT_EQ(out_path, expected_path);
28
29 EXPECT_TRUE(PnaclCanOpenFile("x86-32/llc", &out_path));
30 expected_path = kDummyPnaclPath.Append(FILE_PATH_LITERAL("x86-32/llc"));
31 EXPECT_EQ(out_path, expected_path);
32
33 EXPECT_FALSE(PnaclCanOpenFile("", &out_path));
34 EXPECT_FALSE(PnaclCanOpenFile(".", &out_path));
35 EXPECT_FALSE(PnaclCanOpenFile("..", &out_path));
36 #if defined(OS_WIN)
37 EXPECT_FALSE(PnaclCanOpenFile("..\\llc", &out_path));
38 EXPECT_FALSE(PnaclCanOpenFile("%SystemRoot%", &out_path));
39 EXPECT_FALSE(PnaclCanOpenFile("%SystemRoot%\\explorer.exe", &out_path));
40 #else
41 EXPECT_FALSE(PnaclCanOpenFile("../llc", &out_path));
42 EXPECT_FALSE(PnaclCanOpenFile("/bin/sh", &out_path));
43 EXPECT_FALSE(PnaclCanOpenFile("$HOME", &out_path));
44 EXPECT_FALSE(PnaclCanOpenFile("$HOME/.bashrc", &out_path));
45 #endif
46
47 const char non_ascii[] = "\xff\xfe";
48 EXPECT_FALSE(PnaclCanOpenFile(non_ascii, &out_path));
49 }
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/pnacl_file_host.cc ('k') | chrome/browser/renderer_host/chrome_render_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698