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 <stdint.h> |
| 8 |
7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
8 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
9 #include "chrome/browser/safe_browsing/local_two_phase_testserver.h" | 11 #include "chrome/browser/safe_browsing/local_two_phase_testserver.h" |
10 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
11 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
12 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
13 #include "net/url_request/url_fetcher.h" | 15 #include "net/url_request/url_fetcher.h" |
14 #include "net/url_request/url_request_test_util.h" | 16 #include "net/url_request/url_request_test_util.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
16 | 18 |
17 using content::BrowserThread; | 19 using content::BrowserThread; |
18 using content::MessageLoopRunner; | 20 using content::MessageLoopRunner; |
19 | 21 |
20 namespace safe_browsing { | 22 namespace safe_browsing { |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 class Delegate { | 26 class Delegate { |
25 public: | 27 public: |
26 Delegate() : state_(TwoPhaseUploader::STATE_NONE) { | 28 Delegate() : state_(TwoPhaseUploader::STATE_NONE) { |
27 } | 29 } |
28 | 30 |
29 void ProgressCallback(int64 current, int64 total) {} | 31 void ProgressCallback(int64_t current, int64_t total) {} |
30 | 32 |
31 void FinishCallback(scoped_refptr<MessageLoopRunner> runner, | 33 void FinishCallback(scoped_refptr<MessageLoopRunner> runner, |
32 TwoPhaseUploader::State state, | 34 TwoPhaseUploader::State state, |
33 int net_error, | 35 int net_error, |
34 int response_code, | 36 int response_code, |
35 const std::string& response) { | 37 const std::string& response) { |
36 state_ = state; | 38 state_ = state; |
37 net_error_ = net_error; | 39 net_error_ = net_error; |
38 response_code_ = response_code; | 40 response_code_ = response_code; |
39 response_ = response; | 41 response_ = response; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 &Delegate::FinishCallback, base::Unretained(&delegate), runner))); | 186 &Delegate::FinishCallback, base::Unretained(&delegate), runner))); |
185 uploader->Start(); | 187 uploader->Start(); |
186 runner->Run(); | 188 runner->Run(); |
187 EXPECT_EQ(TwoPhaseUploader::UPLOAD_FILE, delegate.state_); | 189 EXPECT_EQ(TwoPhaseUploader::UPLOAD_FILE, delegate.state_); |
188 EXPECT_EQ(net::ERR_EMPTY_RESPONSE, delegate.net_error_); | 190 EXPECT_EQ(net::ERR_EMPTY_RESPONSE, delegate.net_error_); |
189 EXPECT_EQ(net::URLFetcher::RESPONSE_CODE_INVALID, delegate.response_code_); | 191 EXPECT_EQ(net::URLFetcher::RESPONSE_CODE_INVALID, delegate.response_code_); |
190 EXPECT_EQ("", delegate.response_); | 192 EXPECT_EQ("", delegate.response_); |
191 } | 193 } |
192 | 194 |
193 } // namespace safe_browsing | 195 } // namespace safe_browsing |
OLD | NEW |