OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Browser tests targeted at the RenderView that run in browser context. | 5 // Browser tests targeted at the RenderView that run in browser context. |
6 // Note that these tests rely on single-process mode, and hence may be | 6 // Note that these tests rely on single-process mode, and hence may be |
7 // disabled in some configurations (check gyp files). | 7 // disabled in some configurations (check gyp files). |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void InterceptNetworkTransactions(net::URLRequestContextGetter* getter, | 81 void InterceptNetworkTransactions(net::URLRequestContextGetter* getter, |
82 net::Error error) { | 82 net::Error error) { |
83 DCHECK(content::BrowserThread::CurrentlyOn(BrowserThread::IO)); | 83 DCHECK(content::BrowserThread::CurrentlyOn(BrowserThread::IO)); |
84 net::HttpCache* cache( | 84 net::HttpCache* cache( |
85 getter->GetURLRequestContext()->http_transaction_factory()->GetCache()); | 85 getter->GetURLRequestContext()->http_transaction_factory()->GetCache()); |
86 DCHECK(cache); | 86 DCHECK(cache); |
87 scoped_ptr<net::FailingHttpTransactionFactory> factory( | 87 scoped_ptr<net::FailingHttpTransactionFactory> factory( |
88 new net::FailingHttpTransactionFactory(cache->GetSession(), error)); | 88 new net::FailingHttpTransactionFactory(cache->GetSession(), error)); |
89 // Throw away old version; since this is a browser test, there is no | 89 // Throw away old version; since this is a browser test, there is no |
90 // need to restore the old state. | 90 // need to restore the old state. |
91 cache->SetHttpNetworkTransactionFactoryForTesting( | 91 cache->SetHttpNetworkTransactionFactoryForTesting(factory.Pass()); |
92 factory.PassAs<net::HttpTransactionFactory>()); | |
93 } | 92 } |
94 | 93 |
95 void CallOnUIThreadValidatingReturn(const base::Closure& callback, | 94 void CallOnUIThreadValidatingReturn(const base::Closure& callback, |
96 int rv) { | 95 int rv) { |
97 DCHECK_EQ(net::OK, rv); | 96 DCHECK_EQ(net::OK, rv); |
98 BrowserThread::PostTask( | 97 BrowserThread::PostTask( |
99 BrowserThread::UI, FROM_HERE, callback); | 98 BrowserThread::UI, FROM_HERE, callback); |
100 } | 99 } |
101 | 100 |
102 // Must be called on IO thread. The callback will be called on | 101 // Must be called on IO thread. The callback will be called on |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 235 |
237 error_code = net::OK; | 236 error_code = net::OK; |
238 stale_cache_entry_present = true; | 237 stale_cache_entry_present = true; |
239 ASSERT_TRUE(GetLatestErrorFromRendererClient( | 238 ASSERT_TRUE(GetLatestErrorFromRendererClient( |
240 &error_code, &stale_cache_entry_present)); | 239 &error_code, &stale_cache_entry_present)); |
241 EXPECT_EQ(net::ERR_FAILED, error_code); | 240 EXPECT_EQ(net::ERR_FAILED, error_code); |
242 EXPECT_FALSE(stale_cache_entry_present); | 241 EXPECT_FALSE(stale_cache_entry_present); |
243 } | 242 } |
244 | 243 |
245 } // namespace content | 244 } // namespace content |
OLD | NEW |