| OLD | NEW |
| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 class IOThread : public base::Thread { | 529 class IOThread : public base::Thread { |
| 530 public: | 530 public: |
| 531 explicit IOThread(const char* name) | 531 explicit IOThread(const char* name) |
| 532 : base::Thread(name) { | 532 : base::Thread(name) { |
| 533 } | 533 } |
| 534 | 534 |
| 535 ~IOThread() { | 535 ~IOThread() { |
| 536 Stop(); | 536 Stop(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 const scoped_refptr<net::URLRequestContext>& request_context() { | 539 net::URLRequestContext* request_context() { |
| 540 return request_context_; | 540 return request_context_.get(); |
| 541 } | 541 } |
| 542 | 542 |
| 543 void SetNewJobFactory(net::URLRequestJobFactory* job_factory) { | 543 void SetNewJobFactory(net::URLRequestJobFactory* job_factory) { |
| 544 DCHECK(job_factory); | 544 DCHECK(job_factory); |
| 545 job_factory_.reset(job_factory); | 545 job_factory_.reset(job_factory); |
| 546 request_context_->set_job_factory(job_factory_.get()); | 546 request_context_->set_job_factory(job_factory_.get()); |
| 547 } | 547 } |
| 548 | 548 |
| 549 virtual void Init() { | 549 virtual void Init() { |
| 550 job_factory_.reset(new net::URLRequestJobFactory); | 550 job_factory_.reset(new net::URLRequestJobFactory); |
| 551 job_factory_->SetProtocolHandler("http", new MockHttpServerJobFactory); | 551 job_factory_->SetProtocolHandler("http", new MockHttpServerJobFactory); |
| 552 job_factory_->SetProtocolHandler("https", new MockHttpServerJobFactory); | 552 job_factory_->SetProtocolHandler("https", new MockHttpServerJobFactory); |
| 553 request_context_ = new TestURLRequestContext(); | 553 request_context_.reset(new TestURLRequestContext()); |
| 554 request_context_->set_job_factory(job_factory_.get()); | 554 request_context_->set_job_factory(job_factory_.get()); |
| 555 } | 555 } |
| 556 | 556 |
| 557 virtual void CleanUp() { | 557 virtual void CleanUp() { |
| 558 request_context_ = NULL; | 558 request_context_.reset(); |
| 559 job_factory_.reset(); | 559 job_factory_.reset(); |
| 560 } | 560 } |
| 561 | 561 |
| 562 private: | 562 private: |
| 563 scoped_ptr<net::URLRequestJobFactory> job_factory_; | 563 scoped_ptr<net::URLRequestJobFactory> job_factory_; |
| 564 scoped_refptr<net::URLRequestContext> request_context_; | 564 scoped_ptr<net::URLRequestContext> request_context_; |
| 565 }; | 565 }; |
| 566 | 566 |
| 567 class AppCacheUpdateJobTest : public testing::Test, | 567 class AppCacheUpdateJobTest : public testing::Test, |
| 568 public AppCacheGroup::UpdateObserver { | 568 public AppCacheGroup::UpdateObserver { |
| 569 public: | 569 public: |
| 570 AppCacheUpdateJobTest() | 570 AppCacheUpdateJobTest() |
| 571 : do_checks_after_update_finished_(false), | 571 : do_checks_after_update_finished_(false), |
| 572 expect_group_obsolete_(false), | 572 expect_group_obsolete_(false), |
| 573 expect_group_has_cache_(false), | 573 expect_group_has_cache_(false), |
| 574 expect_group_is_being_deleted_(false), | 574 expect_group_is_being_deleted_(false), |
| (...skipping 2992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3567 | 3567 |
| 3568 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { | 3568 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { |
| 3569 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); | 3569 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); |
| 3570 } | 3570 } |
| 3571 | 3571 |
| 3572 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { | 3572 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { |
| 3573 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); | 3573 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); |
| 3574 } | 3574 } |
| 3575 | 3575 |
| 3576 } // namespace appcache | 3576 } // namespace appcache |
| OLD | NEW |