OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/nacl/browser/nacl_file_host.h" | 5 #include "components/nacl/browser/nacl_file_host.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
10 #include "base/test/scoped_path_override.h" | 11 #include "base/test/scoped_path_override.h" |
11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
12 #include "components/nacl/browser/nacl_browser.h" | 13 #include "components/nacl/browser/nacl_browser.h" |
13 #include "components/nacl/browser/nacl_browser_delegate.h" | 14 #include "components/nacl/browser/nacl_browser_delegate.h" |
14 #include "components/nacl/browser/test_nacl_browser_delegate.h" | 15 #include "components/nacl/browser/test_nacl_browser_delegate.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 using nacl_file_host::PnaclCanOpenFile; | 18 using nacl_file_host::PnaclCanOpenFile; |
18 | 19 |
19 class FileHostTestNaClBrowserDelegate : public TestNaClBrowserDelegate { | 20 class FileHostTestNaClBrowserDelegate : public TestNaClBrowserDelegate { |
(...skipping 13 matching lines...) Expand all Loading... |
33 base::FilePath pnacl_path_; | 34 base::FilePath pnacl_path_; |
34 }; | 35 }; |
35 | 36 |
36 class NaClFileHostTest : public testing::Test { | 37 class NaClFileHostTest : public testing::Test { |
37 protected: | 38 protected: |
38 NaClFileHostTest(); | 39 NaClFileHostTest(); |
39 ~NaClFileHostTest() override; | 40 ~NaClFileHostTest() override; |
40 | 41 |
41 void SetUp() override { | 42 void SetUp() override { |
42 nacl_browser_delegate_ = new FileHostTestNaClBrowserDelegate; | 43 nacl_browser_delegate_ = new FileHostTestNaClBrowserDelegate; |
43 nacl::NaClBrowser::SetDelegate(nacl_browser_delegate_); | 44 nacl::NaClBrowser::SetDelegate(base::WrapUnique(nacl_browser_delegate_)); |
44 } | 45 } |
45 | 46 |
46 void TearDown() override { | 47 void TearDown() override { |
47 // This deletes nacl_browser_delegate_. | 48 nacl_browser_delegate_ = nullptr; |
48 nacl::NaClBrowser::SetDelegate(NULL); | 49 nacl::NaClBrowser::ClearAndDeleteDelegateForTest(); |
49 } | 50 } |
50 | 51 |
51 FileHostTestNaClBrowserDelegate* nacl_browser_delegate() { | 52 FileHostTestNaClBrowserDelegate* nacl_browser_delegate() { |
52 return nacl_browser_delegate_; | 53 return nacl_browser_delegate_; |
53 } | 54 } |
54 | 55 |
55 private: | 56 private: |
56 FileHostTestNaClBrowserDelegate* nacl_browser_delegate_; | 57 FileHostTestNaClBrowserDelegate* nacl_browser_delegate_; |
57 DISALLOW_COPY_AND_ASSIGN(NaClFileHostTest); | 58 DISALLOW_COPY_AND_ASSIGN(NaClFileHostTest); |
58 }; | 59 }; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 EXPECT_FALSE(PnaclCanOpenFile("..\\llc", &out_path)); | 112 EXPECT_FALSE(PnaclCanOpenFile("..\\llc", &out_path)); |
112 EXPECT_FALSE(PnaclCanOpenFile("%SystemRoot%", &out_path)); | 113 EXPECT_FALSE(PnaclCanOpenFile("%SystemRoot%", &out_path)); |
113 EXPECT_FALSE(PnaclCanOpenFile("%SystemRoot%\\explorer.exe", &out_path)); | 114 EXPECT_FALSE(PnaclCanOpenFile("%SystemRoot%\\explorer.exe", &out_path)); |
114 #else | 115 #else |
115 EXPECT_FALSE(PnaclCanOpenFile("../llc", &out_path)); | 116 EXPECT_FALSE(PnaclCanOpenFile("../llc", &out_path)); |
116 EXPECT_FALSE(PnaclCanOpenFile("/bin/sh", &out_path)); | 117 EXPECT_FALSE(PnaclCanOpenFile("/bin/sh", &out_path)); |
117 EXPECT_FALSE(PnaclCanOpenFile("$HOME", &out_path)); | 118 EXPECT_FALSE(PnaclCanOpenFile("$HOME", &out_path)); |
118 EXPECT_FALSE(PnaclCanOpenFile("$HOME/.bashrc", &out_path)); | 119 EXPECT_FALSE(PnaclCanOpenFile("$HOME/.bashrc", &out_path)); |
119 #endif | 120 #endif |
120 } | 121 } |
OLD | NEW |