OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/safe_browsing/two_phase_uploader.h" | 5 #include "chrome/browser/safe_browsing/two_phase_uploader.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/safe_browsing/local_two_phase_testserver.h" | 9 #include "chrome/browser/safe_browsing/local_two_phase_testserver.h" |
10 #include "content/public/test/test_browser_thread.h" | 10 #include "content/public/test/test_browser_thread.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 io_thread_(BrowserThread::IO, &message_loop_), | 63 io_thread_(BrowserThread::IO, &message_loop_), |
64 url_request_context_getter_(new net::TestURLRequestContextGetter( | 64 url_request_context_getter_(new net::TestURLRequestContextGetter( |
65 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))) { | 65 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))) { |
66 } | 66 } |
67 | 67 |
68 virtual void SetUp() { | 68 virtual void SetUp() { |
69 db_thread_.Start(); | 69 db_thread_.Start(); |
70 } | 70 } |
71 | 71 |
72 protected: | 72 protected: |
73 MessageLoopForIO message_loop_; | 73 base::MessageLoopForIO message_loop_; |
74 content::TestBrowserThread db_thread_; | 74 content::TestBrowserThread db_thread_; |
75 content::TestBrowserThread io_thread_; | 75 content::TestBrowserThread io_thread_; |
76 | 76 |
77 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 77 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
78 }; | 78 }; |
79 | 79 |
80 TEST_F(TwoPhaseUploaderTest, UploadFile) { | 80 TEST_F(TwoPhaseUploaderTest, UploadFile) { |
81 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; | 81 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; |
82 LocalTwoPhaseTestServer test_server; | 82 LocalTwoPhaseTestServer test_server; |
83 ASSERT_TRUE(test_server.Start()); | 83 ASSERT_TRUE(test_server.Start()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 base::Bind(&Delegate::ProgressCallback, base::Unretained(&delegate)), | 187 base::Bind(&Delegate::ProgressCallback, base::Unretained(&delegate)), |
188 base::Bind(&Delegate::FinishCallback, base::Unretained(&delegate), | 188 base::Bind(&Delegate::FinishCallback, base::Unretained(&delegate), |
189 runner))); | 189 runner))); |
190 uploader->Start(); | 190 uploader->Start(); |
191 runner->Run(); | 191 runner->Run(); |
192 EXPECT_EQ(TwoPhaseUploader::UPLOAD_FILE, delegate.state_); | 192 EXPECT_EQ(TwoPhaseUploader::UPLOAD_FILE, delegate.state_); |
193 EXPECT_EQ(net::ERR_EMPTY_RESPONSE, delegate.net_error_); | 193 EXPECT_EQ(net::ERR_EMPTY_RESPONSE, delegate.net_error_); |
194 EXPECT_EQ(net::URLFetcher::RESPONSE_CODE_INVALID, delegate.response_code_); | 194 EXPECT_EQ(net::URLFetcher::RESPONSE_CODE_INVALID, delegate.response_code_); |
195 EXPECT_EQ("", delegate.response_); | 195 EXPECT_EQ("", delegate.response_); |
196 } | 196 } |
OLD | NEW |