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

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

Issue 11575027: Remove SafeBrowsingProtocolManagerTest.EmptyDatabase test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 5
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 true))); 329 true)));
330 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1); 330 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1);
331 331
332 scoped_ptr<SafeBrowsingProtocolManager> pm( 332 scoped_ptr<SafeBrowsingProtocolManager> pm(
333 CreateProtocolManager(&test_delegate)); 333 CreateProtocolManager(&test_delegate));
334 334
335 pm->ForceScheduleNextUpdate(base::TimeDelta()); 335 pm->ForceScheduleNextUpdate(base::TimeDelta());
336 runner->RunTasks(); 336 runner->RunTasks();
337 } 337 }
338 338
339 // Tests the contents of the POST body when the local database is empty.
340 TEST_F(SafeBrowsingProtocolManagerTest, EmptyDatabase) {
341 scoped_refptr<ImmediateSingleThreadTaskRunner> runner(
342 new ImmediateSingleThreadTaskRunner());
343 base::ThreadTaskRunnerHandle runner_handler(runner);
344 net::TestURLFetcherFactory url_fetcher_factory;
345
346 testing::StrictMock<MockProtocolDelegate> test_delegate;
347 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
348 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
349 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
350 std::vector<SBListChunkRanges>(),
351 false)));
352
353 scoped_ptr<SafeBrowsingProtocolManager> pm(
354 CreateProtocolManager(&test_delegate));
355
356 // Kick off initialization. This returns chunks from the DB synchronously.
357 pm->ForceScheduleNextUpdate(base::TimeDelta());
358 runner->RunTasks();
359
360 // We should have an URLFetcher at this point in time.
361 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
362 ValidateUpdateFetcherRequest(url_fetcher);
363 }
364
365 // Tests the contents of the POST body when there are contents in the 339 // Tests the contents of the POST body when there are contents in the
366 // local database. This is not exhaustive, as the actual list formatting 340 // local database. This is not exhaustive, as the actual list formatting
367 // is covered by SafeBrowsingProtocolManagerTest.TestChunkStrings. 341 // is covered by SafeBrowsingProtocolManagerTest.TestChunkStrings.
368 TEST_F(SafeBrowsingProtocolManagerTest, ExistingDatabase) { 342 TEST_F(SafeBrowsingProtocolManagerTest, ExistingDatabase) {
369 scoped_refptr<ImmediateSingleThreadTaskRunner> runner( 343 scoped_refptr<ImmediateSingleThreadTaskRunner> runner(
370 new ImmediateSingleThreadTaskRunner()); 344 new ImmediateSingleThreadTaskRunner());
371 base::ThreadTaskRunnerHandle runner_handler(runner); 345 base::ThreadTaskRunnerHandle runner_handler(runner);
372 net::TestURLFetcherFactory url_fetcher_factory; 346 net::TestURLFetcherFactory url_fetcher_factory;
373 347
374 std::vector<SBListChunkRanges> ranges; 348 std::vector<SBListChunkRanges> ranges;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 // We should have an URLFetcher at this point in time. 570 // We should have an URLFetcher at this point in time.
597 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 571 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
598 ValidateUpdateFetcherRequest(url_fetcher); 572 ValidateUpdateFetcherRequest(url_fetcher);
599 573
600 // The update response is successful, and has a reset command. 574 // The update response is successful, and has a reset command.
601 url_fetcher->set_status(net::URLRequestStatus()); 575 url_fetcher->set_status(net::URLRequestStatus());
602 url_fetcher->set_response_code(200); 576 url_fetcher->set_response_code(200);
603 url_fetcher->SetResponseString("r:pleasereset\n"); 577 url_fetcher->SetResponseString("r:pleasereset\n");
604 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher); 578 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher);
605 } 579 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698