OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014, Google Inc. All rights reserved. | 2 * Copyright (c) 2014, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const char kOriginalRequestDateAsString[] = "Thu, 25 May 1977 18:30:00 GMT"; | 52 const char kOriginalRequestDateAsString[] = "Thu, 25 May 1977 18:30:00 GMT"; |
53 const double kOriginalRequestDateAsDouble = 233433000.; | 53 const double kOriginalRequestDateAsDouble = 233433000.; |
54 | 54 |
55 const char kOneDayBeforeOriginalRequest[] = "Wed, 24 May 1977 18:30:00 GMT"; | 55 const char kOneDayBeforeOriginalRequest[] = "Wed, 24 May 1977 18:30:00 GMT"; |
56 const char kOneDayAfterOriginalRequest[] = "Fri, 26 May 1977 18:30:00 GMT"; | 56 const char kOneDayAfterOriginalRequest[] = "Fri, 26 May 1977 18:30:00 GMT"; |
57 | 57 |
58 const unsigned char kAConstUnsignedCharZero = 0; | 58 const unsigned char kAConstUnsignedCharZero = 0; |
59 | 59 |
60 class MockFetchContext : public FetchContext { | 60 class MockFetchContext : public FetchContext { |
61 public: | 61 public: |
62 static PassOwnPtrWillBeRawPtr<MockFetchContext> create() | 62 static MockFetchContext* create() |
63 { | 63 { |
64 return adoptPtrWillBeNoop(new MockFetchContext); | 64 return new MockFetchContext; |
65 } | 65 } |
66 | 66 |
67 ~MockFetchContext() { } | 67 ~MockFetchContext() { } |
68 | 68 |
69 bool allowImage(bool imagesEnabled, const KURL&) const override { return tru
e; } | 69 bool allowImage(bool imagesEnabled, const KURL&) const override { return tru
e; } |
70 bool canRequest(Resource::Type, const ResourceRequest&, const KURL&, const R
esourceLoaderOptions&, bool forPreload, FetchRequest::OriginRestriction) const o
verride { return true; } | 70 bool canRequest(Resource::Type, const ResourceRequest&, const KURL&, const R
esourceLoaderOptions&, bool forPreload, FetchRequest::OriginRestriction) const o
verride { return true; } |
71 | 71 |
72 private: | 72 private: |
73 MockFetchContext() { } | 73 MockFetchContext() { } |
74 }; | 74 }; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 virtual void TearDown() | 170 virtual void TearDown() |
171 { | 171 { |
172 memoryCache()->evictResources(); | 172 memoryCache()->evictResources(); |
173 | 173 |
174 // Yield the ownership of the global memory cache back. | 174 // Yield the ownership of the global memory cache back. |
175 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); | 175 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); |
176 } | 176 } |
177 | 177 |
178 ProxyPlatform m_proxyPlatform; | 178 ProxyPlatform m_proxyPlatform; |
179 | 179 |
180 OwnPtrWillBePersistent<MemoryCache> m_globalMemoryCache; | 180 Persistent<MemoryCache> m_globalMemoryCache; |
181 RefPtrWillBePersistent<ResourceFetcher> m_fetcher; | 181 Persistent<ResourceFetcher> m_fetcher; |
182 }; | 182 }; |
183 | 183 |
184 TEST_F(CachingCorrectnessTest, FreshFromLastModified) | 184 TEST_F(CachingCorrectnessTest, FreshFromLastModified) |
185 { | 185 { |
186 ResourceResponse fresh200Response; | 186 ResourceResponse fresh200Response; |
187 fresh200Response.setHTTPStatusCode(200); | 187 fresh200Response.setHTTPStatusCode(200); |
188 fresh200Response.setHTTPHeaderField("Date", kOriginalRequestDateAsString); | 188 fresh200Response.setHTTPHeaderField("Date", kOriginalRequestDateAsString); |
189 fresh200Response.setHTTPHeaderField("Last-Modified", kOneDayBeforeOriginalRe
quest); | 189 fresh200Response.setHTTPHeaderField("Last-Modified", kOneDayBeforeOriginalRe
quest); |
190 | 190 |
191 ResourcePtr<Resource> fresh200 = resourceFromResourceResponse(fresh200Respon
se); | 191 ResourcePtr<Resource> fresh200 = resourceFromResourceResponse(fresh200Respon
se); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 firstResource->setResponse(fresh200Response); | 574 firstResource->setResponse(fresh200Response); |
575 memoryCache()->add(firstResource.get()); | 575 memoryCache()->add(firstResource.get()); |
576 | 576 |
577 advanceClock(500.); | 577 advanceClock(500.); |
578 | 578 |
579 ResourcePtr<Resource> fetched = fetch(); | 579 ResourcePtr<Resource> fetched = fetch(); |
580 EXPECT_EQ(firstResource, fetched); | 580 EXPECT_EQ(firstResource, fetched); |
581 } | 581 } |
582 | 582 |
583 } // namespace blink | 583 } // namespace blink |
OLD | NEW |