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

Side by Side Diff: chrome/browser/safe_browsing/two_phase_uploader_unittest.cc

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Other minor fixes incl. using "using safe_browsing::ClassName" instead of safe_browsing::ClassName everywhere. Created 5 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
OLDNEW
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/message_loop.h" 8 #include "base/message_loop/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_bundle.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "content/public/test/test_utils.h" 11 #include "content/public/test/test_utils.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/url_request/url_fetcher.h" 13 #include "net/url_request/url_fetcher.h"
14 #include "net/url_request/url_request_test_util.h" 14 #include "net/url_request/url_request_test_util.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using content::BrowserThread; 17 using content::BrowserThread;
18 using content::MessageLoopRunner; 18 using content::MessageLoopRunner;
19 19
20 namespace { 20 namespace safe_browsing {
21 21
22 class Delegate { 22 class Delegate {
23 public: 23 public:
24 Delegate() : state_(TwoPhaseUploader::STATE_NONE) { 24 Delegate() : state_(TwoPhaseUploader::STATE_NONE) {
25 } 25 }
26 26
27 void ProgressCallback(int64 current, int64 total) {} 27 void ProgressCallback(int64 current, int64 total) {}
28 28
29 void FinishCallback(scoped_refptr<MessageLoopRunner> runner, 29 void FinishCallback(scoped_refptr<MessageLoopRunner> runner,
30 TwoPhaseUploader::State state, 30 TwoPhaseUploader::State state,
(...skipping 16 matching lines...) Expand all
47 base::FilePath GetTestFilePath() { 47 base::FilePath GetTestFilePath() {
48 base::FilePath file_path; 48 base::FilePath file_path;
49 PathService::Get(base::DIR_SOURCE_ROOT, &file_path); 49 PathService::Get(base::DIR_SOURCE_ROOT, &file_path);
50 file_path = file_path.Append(FILE_PATH_LITERAL("net")); 50 file_path = file_path.Append(FILE_PATH_LITERAL("net"));
51 file_path = file_path.Append(FILE_PATH_LITERAL("data")); 51 file_path = file_path.Append(FILE_PATH_LITERAL("data"));
52 file_path = file_path.Append(FILE_PATH_LITERAL("url_request_unittest")); 52 file_path = file_path.Append(FILE_PATH_LITERAL("url_request_unittest"));
53 file_path = file_path.Append(FILE_PATH_LITERAL("BullRunSpeech.txt")); 53 file_path = file_path.Append(FILE_PATH_LITERAL("BullRunSpeech.txt"));
54 return file_path; 54 return file_path;
55 } 55 }
56 56
57 } // namespace
mattm 2015/11/11 01:10:16 Keep the anon namespace inside the new namespace.
vakh (old account. dont use) 2015/11/11 18:59:53 Done.
58
59 class TwoPhaseUploaderTest : public testing::Test { 57 class TwoPhaseUploaderTest : public testing::Test {
60 public: 58 public:
61 TwoPhaseUploaderTest() 59 TwoPhaseUploaderTest()
62 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 60 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
63 url_request_context_getter_(new net::TestURLRequestContextGetter( 61 url_request_context_getter_(new net::TestURLRequestContextGetter(
64 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))) { 62 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))) {
65 } 63 }
66 64
67 protected: 65 protected:
68 content::TestBrowserThreadBundle thread_bundle_; 66 content::TestBrowserThreadBundle thread_bundle_;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 base::Bind(&Delegate::ProgressCallback, base::Unretained(&delegate)), 178 base::Bind(&Delegate::ProgressCallback, base::Unretained(&delegate)),
181 base::Bind( 179 base::Bind(
182 &Delegate::FinishCallback, base::Unretained(&delegate), runner))); 180 &Delegate::FinishCallback, base::Unretained(&delegate), runner)));
183 uploader->Start(); 181 uploader->Start();
184 runner->Run(); 182 runner->Run();
185 EXPECT_EQ(TwoPhaseUploader::UPLOAD_FILE, delegate.state_); 183 EXPECT_EQ(TwoPhaseUploader::UPLOAD_FILE, delegate.state_);
186 EXPECT_EQ(net::ERR_EMPTY_RESPONSE, delegate.net_error_); 184 EXPECT_EQ(net::ERR_EMPTY_RESPONSE, delegate.net_error_);
187 EXPECT_EQ(net::URLFetcher::RESPONSE_CODE_INVALID, delegate.response_code_); 185 EXPECT_EQ(net::URLFetcher::RESPONSE_CODE_INVALID, delegate.response_code_);
188 EXPECT_EQ("", delegate.response_); 186 EXPECT_EQ("", delegate.response_);
189 } 187 }
188
189 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698