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

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

Issue 8400060: Switch content tests to use BrowserThreadImpl directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to lkgr 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 "content/browser/download/base_file.h" 5 #include "content/browser/download/base_file.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/test/test_file_util.h" 12 #include "base/test/test_file_util.h"
13 #include "content/test/test_browser_thread.h" 13 #include "content/browser/browser_thread_impl.h"
14 #include "net/base/file_stream.h" 14 #include "net/base/file_stream.h"
15 #include "net/base/mock_file_stream.h" 15 #include "net/base/mock_file_stream.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 using content::BrowserThreadImpl;
20
19 namespace { 21 namespace {
20 22
21 const char kTestData1[] = "Let's write some data to the file!\n"; 23 const char kTestData1[] = "Let's write some data to the file!\n";
22 const char kTestData2[] = "Writing more data.\n"; 24 const char kTestData2[] = "Writing more data.\n";
23 const char kTestData3[] = "Final line."; 25 const char kTestData3[] = "Final line.";
24 const char kTestData4[] = "supercalifragilisticexpialidocious"; 26 const char kTestData4[] = "supercalifragilisticexpialidocious";
25 const int kTestDataLength1 = arraysize(kTestData1) - 1; 27 const int kTestDataLength1 = arraysize(kTestData1) - 1;
26 const int kTestDataLength2 = arraysize(kTestData2) - 1; 28 const int kTestDataLength2 = arraysize(kTestData2) - 1;
27 const int kTestDataLength3 = arraysize(kTestData3) - 1; 29 const int kTestDataLength3 = arraysize(kTestData3) - 1;
28 const int kTestDataLength4 = arraysize(kTestData4) - 1; 30 const int kTestDataLength4 = arraysize(kTestData4) - 1;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // Expect the file to be in progress. 157 // Expect the file to be in progress.
156 bool expect_in_progress_; 158 bool expect_in_progress_;
157 159
158 private: 160 private:
159 // Keep track of what data should be saved to the disk file. 161 // Keep track of what data should be saved to the disk file.
160 std::string expected_data_; 162 std::string expected_data_;
161 bool expected_error_; 163 bool expected_error_;
162 164
163 // Mock file thread to satisfy debug checks in BaseFile. 165 // Mock file thread to satisfy debug checks in BaseFile.
164 MessageLoop message_loop_; 166 MessageLoop message_loop_;
165 content::TestBrowserThread file_thread_; 167 BrowserThreadImpl file_thread_;
166 }; 168 };
167 169
168 // Test the most basic scenario: just create the object and do a sanity check 170 // Test the most basic scenario: just create the object and do a sanity check
169 // on all its accessors. This is actually a case that rarely happens 171 // on all its accessors. This is actually a case that rarely happens
170 // in production, where we would at least Initialize it. 172 // in production, where we would at least Initialize it.
171 TEST_F(BaseFileTest, CreateDestroy) { 173 TEST_F(BaseFileTest, CreateDestroy) {
172 EXPECT_EQ(FilePath().value(), base_file_->full_path().value()); 174 EXPECT_EQ(FilePath().value(), base_file_->full_path().value());
173 } 175 }
174 176
175 // Cancel the download explicitly. 177 // Cancel the download explicitly.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 396
395 // Write into the file. 397 // Write into the file.
396 EXPECT_NE(net::OK, AppendDataToFile(kTestData1)); 398 EXPECT_NE(net::OK, AppendDataToFile(kTestData1));
397 399
398 base_file_->Finish(); 400 base_file_->Finish();
399 base_file_->Detach(); 401 base_file_->Detach();
400 expect_file_survives_ = true; 402 expect_file_survives_ = true;
401 } 403 }
402 404
403 } // namespace 405 } // namespace
OLDNEW
« no previous file with comments | « content/browser/appcache/chrome_appcache_service_unittest.cc ('k') | content/browser/download/download_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698