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

Side by Side Diff: webkit/appcache/appcache_update_job_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | « ui/gl/gl_surface.cc ('k') | webkit/fileapi/copy_or_move_file_validator_unittest.cc » ('j') | 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 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 2631 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 io_thread_->SetNewJobFactory(new_factory); 2642 io_thread_->SetNewJobFactory(new_factory);
2643 2643
2644 MakeService(); 2644 MakeService();
2645 group_ = new AppCacheGroup( 2645 group_ = new AppCacheGroup(
2646 service_->storage(), GURL("http://headertest"), 111); 2646 service_->storage(), GURL("http://headertest"), 111);
2647 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 2647 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
2648 group_->update_job_ = update; 2648 group_->update_job_ = update;
2649 2649
2650 // First test against a cache attempt. Will start manifest fetch 2650 // First test against a cache attempt. Will start manifest fetch
2651 // synchronously. 2651 // synchronously.
2652 HttpHeadersRequestTestJob::Initialize("", ""); 2652 HttpHeadersRequestTestJob::Initialize(std::string(), std::string());
2653 MockFrontend mock_frontend; 2653 MockFrontend mock_frontend;
2654 AppCacheHost host(1, &mock_frontend, service_.get()); 2654 AppCacheHost host(1, &mock_frontend, service_.get());
2655 update->StartUpdate(&host, GURL()); 2655 update->StartUpdate(&host, GURL());
2656 HttpHeadersRequestTestJob::Verify(); 2656 HttpHeadersRequestTestJob::Verify();
2657 delete update; 2657 delete update;
2658 2658
2659 // Now simulate a refetch manifest request. Will start fetch request 2659 // Now simulate a refetch manifest request. Will start fetch request
2660 // synchronously. 2660 // synchronously.
2661 const char data[] = 2661 const char data[] =
2662 "HTTP/1.1 200 OK\0" 2662 "HTTP/1.1 200 OK\0"
2663 "\0"; 2663 "\0";
2664 net::HttpResponseHeaders* headers = 2664 net::HttpResponseHeaders* headers =
2665 new net::HttpResponseHeaders(std::string(data, arraysize(data))); 2665 new net::HttpResponseHeaders(std::string(data, arraysize(data)));
2666 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); 2666 net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
2667 response_info->headers = headers; // adds ref to headers 2667 response_info->headers = headers; // adds ref to headers
2668 2668
2669 HttpHeadersRequestTestJob::Initialize("", ""); 2669 HttpHeadersRequestTestJob::Initialize(std::string(), std::string());
2670 update = new AppCacheUpdateJob(service_.get(), group_); 2670 update = new AppCacheUpdateJob(service_.get(), group_);
2671 group_->update_job_ = update; 2671 group_->update_job_ = update;
2672 group_->update_status_ = AppCacheGroup::DOWNLOADING; 2672 group_->update_status_ = AppCacheGroup::DOWNLOADING;
2673 update->manifest_response_info_.reset(response_info); 2673 update->manifest_response_info_.reset(response_info);
2674 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST; 2674 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST;
2675 update->FetchManifest(false); // not first request 2675 update->FetchManifest(false); // not first request
2676 HttpHeadersRequestTestJob::Verify(); 2676 HttpHeadersRequestTestJob::Verify();
2677 delete update; 2677 delete update;
2678 2678
2679 // Change the headers to include a Last-Modified header. Manifest refetch 2679 // Change the headers to include a Last-Modified header. Manifest refetch
2680 // should include If-Modified-Since header. 2680 // should include If-Modified-Since header.
2681 const char data2[] = 2681 const char data2[] =
2682 "HTTP/1.1 200 OK\0" 2682 "HTTP/1.1 200 OK\0"
2683 "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0" 2683 "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0"
2684 "\0"; 2684 "\0";
2685 net::HttpResponseHeaders* headers2 = 2685 net::HttpResponseHeaders* headers2 =
2686 new net::HttpResponseHeaders(std::string(data2, arraysize(data2))); 2686 new net::HttpResponseHeaders(std::string(data2, arraysize(data2)));
2687 response_info = new net::HttpResponseInfo(); 2687 response_info = new net::HttpResponseInfo();
2688 response_info->headers = headers2; 2688 response_info->headers = headers2;
2689 2689
2690 HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT", ""); 2690 HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT",
2691 std::string());
2691 update = new AppCacheUpdateJob(service_.get(), group_); 2692 update = new AppCacheUpdateJob(service_.get(), group_);
2692 group_->update_job_ = update; 2693 group_->update_job_ = update;
2693 group_->update_status_ = AppCacheGroup::DOWNLOADING; 2694 group_->update_status_ = AppCacheGroup::DOWNLOADING;
2694 update->manifest_response_info_.reset(response_info); 2695 update->manifest_response_info_.reset(response_info);
2695 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST; 2696 update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST;
2696 update->FetchManifest(false); // not first request 2697 update->FetchManifest(false); // not first request
2697 HttpHeadersRequestTestJob::Verify(); 2698 HttpHeadersRequestTestJob::Verify();
2698 delete update; 2699 delete update;
2699 2700
2700 UpdateFinished(); 2701 UpdateFinished();
2701 } 2702 }
2702 2703
2703 void IfModifiedSinceUpgradeTest() { 2704 void IfModifiedSinceUpgradeTest() {
2704 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); 2705 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type());
2705 2706
2706 HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT", ""); 2707 HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT",
2708 std::string());
2707 net::URLRequestJobFactoryImpl* new_factory( 2709 net::URLRequestJobFactoryImpl* new_factory(
2708 new net::URLRequestJobFactoryImpl); 2710 new net::URLRequestJobFactoryImpl);
2709 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); 2711 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory);
2710 io_thread_->SetNewJobFactory(new_factory); 2712 io_thread_->SetNewJobFactory(new_factory);
2711 2713
2712 MakeService(); 2714 MakeService();
2713 group_ =new AppCacheGroup( 2715 group_ =new AppCacheGroup(
2714 service_->storage(), 2716 service_->storage(),
2715 MockHttpServer::GetMockUrl("files/manifest1"), 2717 MockHttpServer::GetMockUrl("files/manifest1"),
2716 111); 2718 111);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2758 io_buffer, 2760 io_buffer,
2759 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, 2761 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData,
2760 base::Unretained(this))); 2762 base::Unretained(this)));
2761 2763
2762 // Start update after data write completes asynchronously. 2764 // Start update after data write completes asynchronously.
2763 } 2765 }
2764 2766
2765 void IfNoneMatchUpgradeTest() { 2767 void IfNoneMatchUpgradeTest() {
2766 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); 2768 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type());
2767 2769
2768 HttpHeadersRequestTestJob::Initialize("", "\"LadeDade\""); 2770 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\"");
2769 net::URLRequestJobFactoryImpl* new_factory( 2771 net::URLRequestJobFactoryImpl* new_factory(
2770 new net::URLRequestJobFactoryImpl); 2772 new net::URLRequestJobFactoryImpl);
2771 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); 2773 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory);
2772 io_thread_->SetNewJobFactory(new_factory); 2774 io_thread_->SetNewJobFactory(new_factory);
2773 2775
2774 MakeService(); 2776 MakeService();
2775 group_ = new AppCacheGroup( 2777 group_ = new AppCacheGroup(
2776 service_->storage(), 2778 service_->storage(),
2777 MockHttpServer::GetMockUrl("files/manifest1"), 2779 MockHttpServer::GetMockUrl("files/manifest1"),
2778 111); 2780 111);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2820 io_buffer, 2822 io_buffer,
2821 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData, 2823 base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData,
2822 base::Unretained(this))); 2824 base::Unretained(this)));
2823 2825
2824 // Start update after data write completes asynchronously. 2826 // Start update after data write completes asynchronously.
2825 } 2827 }
2826 2828
2827 void IfNoneMatchRefetchTest() { 2829 void IfNoneMatchRefetchTest() {
2828 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); 2830 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type());
2829 2831
2830 HttpHeadersRequestTestJob::Initialize("", "\"LadeDade\""); 2832 HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\"");
2831 net::URLRequestJobFactoryImpl* new_factory( 2833 net::URLRequestJobFactoryImpl* new_factory(
2832 new net::URLRequestJobFactoryImpl); 2834 new net::URLRequestJobFactoryImpl);
2833 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); 2835 new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory);
2834 io_thread_->SetNewJobFactory(new_factory); 2836 io_thread_->SetNewJobFactory(new_factory);
2835 2837
2836 MakeService(); 2838 MakeService();
2837 group_ = new AppCacheGroup( 2839 group_ = new AppCacheGroup(
2838 service_->storage(), GURL("http://headertest"), 111); 2840 service_->storage(), GURL("http://headertest"), 111);
2839 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 2841 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
2840 group_->update_job_ = update; 2842 group_->update_job_ = update;
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
3627 3629
3628 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { 3630 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) {
3629 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); 3631 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest);
3630 } 3632 }
3631 3633
3632 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { 3634 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) {
3633 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); 3635 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest);
3634 } 3636 }
3635 3637
3636 } // namespace appcache 3638 } // namespace appcache
OLDNEW
« no previous file with comments | « ui/gl/gl_surface.cc ('k') | webkit/fileapi/copy_or_move_file_validator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698