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

Side by Side Diff: chrome/common/net/url_fetcher_unittest.cc

Issue 7062006: clang :( (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months 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) 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 "base/message_loop_proxy.h" 5 #include "base/message_loop_proxy.h"
6 #include "base/synchronization/waitable_event.h" 6 #include "base/synchronization/waitable_event.h"
7 #include "base/threading/thread.h" 7 #include "base/threading/thread.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/common/net/url_fetcher.h" 9 #include "chrome/common/net/url_fetcher.h"
10 #include "net/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 class URLFetcherTempFileTest : public URLFetcherTest { 309 class URLFetcherTempFileTest : public URLFetcherTest {
310 public: 310 public:
311 URLFetcherTempFileTest() 311 URLFetcherTempFileTest()
312 : take_ownership_of_temp_file_(false) { 312 : take_ownership_of_temp_file_(false) {
313 } 313 }
314 314
315 // URLFetcher::Delegate 315 // URLFetcher::Delegate
316 virtual void OnURLFetchComplete(const URLFetcher* source); 316 virtual void OnURLFetchComplete(const URLFetcher* source);
317 317
318 // This obsolete signature should not be used, but must be present
319 // to make clang happy.
320 virtual void OnURLFetchComplete(const URLFetcher* source,
321 const GURL& url,
322 const net::URLRequestStatus& status,
323 int response_code,
324 const net::ResponseCookies& cookies,
325 const std::string& data);
326
318 virtual void CreateFetcher(const GURL& url); 327 virtual void CreateFetcher(const GURL& url);
319 328
320 protected: 329 protected:
321 FilePath expected_file_; 330 FilePath expected_file_;
322 FilePath temp_file_; 331 FilePath temp_file_;
323 332
324 // Set by the test. Used in OnURLFetchComplete() to decide if 333 // Set by the test. Used in OnURLFetchComplete() to decide if
325 // the URLFetcher should own the temp file, so that we can test 334 // the URLFetcher should own the temp file, so that we can test
326 // disowning prevents the file from being deleted. 335 // disowning prevents the file from being deleted.
327 bool take_ownership_of_temp_file_; 336 bool take_ownership_of_temp_file_;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 EXPECT_EQ(source->response_code(), 200); 642 EXPECT_EQ(source->response_code(), 200);
634 643
635 EXPECT_TRUE(source->GetResponseAsFilePath( 644 EXPECT_TRUE(source->GetResponseAsFilePath(
636 take_ownership_of_temp_file_, &temp_file_)); 645 take_ownership_of_temp_file_, &temp_file_));
637 646
638 EXPECT_TRUE(file_util::ContentsEqual(expected_file_, temp_file_)); 647 EXPECT_TRUE(file_util::ContentsEqual(expected_file_, temp_file_));
639 648
640 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 649 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
641 } 650 }
642 651
652 void URLFetcherTempFileTest::OnURLFetchComplete(
653 const URLFetcher* source,
654 const GURL& url,
655 const net::URLRequestStatus& status,
656 int response_code,
657 const net::ResponseCookies& cookies,
658 const std::string& data) {
659 NOTREACHED();
660 }
661
662
643 TEST_F(URLFetcherTest, SameThreadsTest) { 663 TEST_F(URLFetcherTest, SameThreadsTest) {
644 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); 664 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot));
645 ASSERT_TRUE(test_server.Start()); 665 ASSERT_TRUE(test_server.Start());
646 666
647 // Create the fetcher on the main thread. Since IO will happen on the main 667 // Create the fetcher on the main thread. Since IO will happen on the main
648 // thread, this will test URLFetcher's ability to do everything on one 668 // thread, this will test URLFetcher's ability to do everything on one
649 // thread. 669 // thread.
650 CreateFetcher(test_server.GetURL("defaultresponse")); 670 CreateFetcher(test_server.GetURL("defaultresponse"));
651 671
652 MessageLoop::current()->Run(); 672 MessageLoop::current()->Run();
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 FROM_HERE, 904 FROM_HERE,
885 new CurriedTask(new MessageLoop::QuitTask(), MessageLoop::current())); 905 new CurriedTask(new MessageLoop::QuitTask(), MessageLoop::current()));
886 MessageLoop::current()->Run(); 906 MessageLoop::current()->Run();
887 EXPECT_EQ(1, GetNumFetcherCores()); 907 EXPECT_EQ(1, GetNumFetcherCores());
888 URLFetcher::CancelAll(); 908 URLFetcher::CancelAll();
889 EXPECT_EQ(0, GetNumFetcherCores()); 909 EXPECT_EQ(0, GetNumFetcherCores());
890 delete fetcher_; 910 delete fetcher_;
891 } 911 }
892 912
893 } // namespace. 913 } // namespace.
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