OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/http/http_cache_transaction.h" | |
6 | |
7 #include "net/http/http_cache.h" | |
8 #include "net/http/http_transaction_unittest.h" | |
9 #include "net/http/mock_http_cache.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 | |
12 namespace net { | |
13 | |
14 class HttpCacheTransactionTest : public ::testing::Test { | |
15 protected: | |
16 typedef HttpCache::Transaction HttpCacheTransaction; | |
17 | |
18 scoped_ptr<HttpCacheTransaction> MakeCacheTransaction() { | |
19 scoped_ptr<HttpTransaction> trans; | |
20 int rv = cache_.http_cache()->CreateTransaction(&trans, NULL); | |
21 EXPECT_EQ(OK, rv); | |
22 return scoped_ptr<HttpCacheTransaction>( | |
23 static_cast<HttpCacheTransaction*>(trans.release())); | |
24 } | |
25 | |
26 MockNetworkTransaction* InjectMockTransaction( | |
27 HttpCacheTransaction* cache_trans) { | |
28 MockNetworkTransaction* mock_trans = new MockNetworkTransaction(&network_); | |
29 cache_trans->network_trans_.reset(mock_trans); | |
30 return mock_trans; | |
31 } | |
32 | |
33 MockNetworkLayer network_; | |
34 MockHttpCache cache_; | |
35 }; | |
36 | |
37 // Make sure that calling HttpCache::Transaction passes on its | |
38 // priority updates to its underlying network transaction. | |
39 TEST_F(HttpCacheTransactionTest, SetPriority) { | |
mmenke
2013/03/13 15:24:38
I believe the HttpCache unittests have all the nec
akalin
2013/03/13 16:06:45
I can't see how; the name HttpCache::Transaction i
mmenke
2013/03/13 16:16:11
They create the MockTransaction before the HttpCac
mmenke
2013/03/13 16:27:28
The same thing I suggested in the other case will
akalin
2013/03/13 16:57:14
Okay that works. Since more than one thing now wan
| |
40 scoped_ptr<HttpCacheTransaction> trans = MakeCacheTransaction(); | |
41 | |
42 trans->SetPriority(LOW); | |
43 | |
44 MockNetworkTransaction* mock_trans = InjectMockTransaction(trans.get()); | |
45 | |
46 EXPECT_EQ(IDLE, mock_trans->priority()); | |
47 | |
48 trans->SetPriority(MEDIUM); | |
49 | |
50 EXPECT_EQ(MEDIUM, mock_trans->priority()); | |
51 } | |
52 | |
53 } // namespace net | |
54 | |
OLD | NEW |