OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 class FileDownloaderTest : public testing::Test { | 24 class FileDownloaderTest : public testing::Test { |
25 public: | 25 public: |
26 FileDownloaderTest() | 26 FileDownloaderTest() |
27 : request_context_(new net::TestURLRequestContextGetter( | 27 : request_context_(new net::TestURLRequestContextGetter( |
28 base::ThreadTaskRunnerHandle::Get())), | 28 base::ThreadTaskRunnerHandle::Get())), |
29 url_fetcher_factory_(nullptr) {} | 29 url_fetcher_factory_(nullptr) {} |
30 | 30 |
31 void SetUp() override { | 31 void SetUp() override { |
32 ASSERT_TRUE(dir_.CreateUniqueTempDir()); | 32 ASSERT_TRUE(dir_.CreateUniqueTempDir()); |
33 path_ = dir_.path().AppendASCII(kFilename); | 33 path_ = dir_.GetPath().AppendASCII(kFilename); |
34 ASSERT_FALSE(base::PathExists(path_)); | 34 ASSERT_FALSE(base::PathExists(path_)); |
35 } | 35 } |
36 | 36 |
37 MOCK_METHOD1(OnDownloadFinished, void(FileDownloader::Result)); | 37 MOCK_METHOD1(OnDownloadFinished, void(FileDownloader::Result)); |
38 | 38 |
39 protected: | 39 protected: |
40 const base::FilePath& path() const { return path_; } | 40 const base::FilePath& path() const { return path_; } |
41 | 41 |
42 void SetValidResponse() { | 42 void SetValidResponse() { |
43 url_fetcher_factory_.SetFakeResponse( | 43 url_fetcher_factory_.SetFakeResponse( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 ASSERT_TRUE(base::ReadFileToString(path(), &contents)); | 121 ASSERT_TRUE(base::ReadFileToString(path(), &contents)); |
122 EXPECT_EQ(std::string(kFileContents1), contents); | 122 EXPECT_EQ(std::string(kFileContents1), contents); |
123 | 123 |
124 SetValidResponse2(); | 124 SetValidResponse2(); |
125 Download(false, FileDownloader::EXISTS); | 125 Download(false, FileDownloader::EXISTS); |
126 // The file should still have the old contents. | 126 // The file should still have the old contents. |
127 EXPECT_TRUE(base::PathExists(path())); | 127 EXPECT_TRUE(base::PathExists(path())); |
128 ASSERT_TRUE(base::ReadFileToString(path(), &contents)); | 128 ASSERT_TRUE(base::ReadFileToString(path(), &contents)); |
129 EXPECT_EQ(std::string(kFileContents1), contents); | 129 EXPECT_EQ(std::string(kFileContents1), contents); |
130 } | 130 } |
OLD | NEW |