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

Side by Side Diff: content/browser/download/download_file_unittest.cc

Issue 8400060: Switch content tests to use BrowserThreadImpl directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "content/browser/browser_thread_impl.h"
8 #include "content/browser/download/download_create_info.h" 9 #include "content/browser/download/download_create_info.h"
9 #include "content/browser/download/download_file.h" 10 #include "content/browser/download/download_file.h"
10 #include "content/browser/download/download_manager.h" 11 #include "content/browser/download/download_manager.h"
11 #include "content/browser/download/download_request_handle.h" 12 #include "content/browser/download/download_request_handle.h"
12 #include "content/browser/download/download_status_updater.h" 13 #include "content/browser/download/download_status_updater.h"
13 #include "content/browser/download/mock_download_manager.h" 14 #include "content/browser/download/mock_download_manager.h"
14 #include "content/browser/download/mock_download_manager_delegate.h" 15 #include "content/browser/download/mock_download_manager_delegate.h"
15 #include "content/test/test_browser_thread.h"
16 #include "net/base/file_stream.h" 16 #include "net/base/file_stream.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 using content::BrowserThreadImpl;
21
20 class DownloadFileTest : public testing::Test { 22 class DownloadFileTest : public testing::Test {
21 public: 23 public:
22 24
23 static const char* kTestData1; 25 static const char* kTestData1;
24 static const char* kTestData2; 26 static const char* kTestData2;
25 static const char* kTestData3; 27 static const char* kTestData3;
26 static const char* kDataHash; 28 static const char* kDataHash;
27 static const int32 kDummyDownloadId; 29 static const int32 kDummyDownloadId;
28 static const int kDummyChildId; 30 static const int kDummyChildId;
29 static const int kDummyRequestId; 31 static const int kDummyRequestId;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 scoped_refptr<DownloadManager> download_manager_; 100 scoped_refptr<DownloadManager> download_manager_;
99 101
100 linked_ptr<net::FileStream> file_stream_; 102 linked_ptr<net::FileStream> file_stream_;
101 103
102 // DownloadFile instance we are testing. 104 // DownloadFile instance we are testing.
103 scoped_ptr<DownloadFile> download_file_; 105 scoped_ptr<DownloadFile> download_file_;
104 106
105 private: 107 private:
106 MessageLoop loop_; 108 MessageLoop loop_;
107 // UI thread. 109 // UI thread.
108 content::TestBrowserThread ui_thread_; 110 BrowserThreadImpl ui_thread_;
109 // File thread to satisfy debug checks in DownloadFile. 111 // File thread to satisfy debug checks in DownloadFile.
110 content::TestBrowserThread file_thread_; 112 BrowserThreadImpl file_thread_;
111 113
112 // Keep track of what data should be saved to the disk file. 114 // Keep track of what data should be saved to the disk file.
113 std::string expected_data_; 115 std::string expected_data_;
114 }; 116 };
115 117
116 const char* DownloadFileTest::kTestData1 = 118 const char* DownloadFileTest::kTestData1 =
117 "Let's write some data to the file!\n"; 119 "Let's write some data to the file!\n";
118 const char* DownloadFileTest::kTestData2 = "Writing more data.\n"; 120 const char* DownloadFileTest::kTestData2 = "Writing more data.\n";
119 const char* DownloadFileTest::kTestData3 = "Final line."; 121 const char* DownloadFileTest::kTestData3 = "Final line.";
120 const char* DownloadFileTest::kDataHash = 122 const char* DownloadFileTest::kDataHash =
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // Check the files. 185 // Check the files.
184 EXPECT_FALSE(file_util::PathExists(path_3)); 186 EXPECT_FALSE(file_util::PathExists(path_3));
185 EXPECT_TRUE(file_util::PathExists(path_4)); 187 EXPECT_TRUE(file_util::PathExists(path_4));
186 188
187 // Check the hash. 189 // Check the hash.
188 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); 190 EXPECT_TRUE(download_file_->GetSha256Hash(&hash));
189 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); 191 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size()));
190 192
191 DestroyDownloadFile(&download_file_, 0); 193 DestroyDownloadFile(&download_file_, 0);
192 } 194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698