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

Side by Side Diff: third_party/WebKit/Source/core/fetch/CachingCorrectnessTest.cpp

Issue 1936853002: Assert event timestamp to be monotonic and not from future Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to histogram Created 4 years, 2 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
OLDNEW
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 virtual void SetUp() 137 virtual void SetUp()
138 { 138 {
139 // Save the global memory cache to restore it upon teardown. 139 // Save the global memory cache to restore it upon teardown.
140 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create() ); 140 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create() );
141 141
142 m_fetcher = ResourceFetcher::create(MockFetchContext::create()); 142 m_fetcher = ResourceFetcher::create(MockFetchContext::create());
143 143
144 s_timeElapsed = 0.0; 144 s_timeElapsed = 0.0;
145 m_originalTimeFunction = setTimeFunctionsForTesting(returnMockTime); 145 m_originalMonotonicTimeFunction = setMonotonicallyIncreasingTimeFunction ForTesting(returnMockTime);
146 m_originalCurrentTimeFunction = setCurrentTimeFunctionForTesting(returnM ockTime);
146 } 147 }
147 148
148 virtual void TearDown() 149 virtual void TearDown()
149 { 150 {
150 memoryCache()->evictResources(); 151 memoryCache()->evictResources();
151 152
152 // Yield the ownership of the global memory cache back. 153 // Yield the ownership of the global memory cache back.
153 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); 154 replaceMemoryCacheForTesting(m_globalMemoryCache.release());
154 155
155 setTimeFunctionsForTesting(m_originalTimeFunction); 156 setMonotonicallyIncreasingTimeFunctionForTesting(m_originalMonotonicTime Function);
157 setCurrentTimeFunctionForTesting(m_originalCurrentTimeFunction);
156 } 158 }
157 159
158 Persistent<MemoryCache> m_globalMemoryCache; 160 Persistent<MemoryCache> m_globalMemoryCache;
159 Persistent<ResourceFetcher> m_fetcher; 161 Persistent<ResourceFetcher> m_fetcher;
160 TimeFunction m_originalTimeFunction; 162 TimeFunction m_originalMonotonicTimeFunction;
163 TimeFunction m_originalCurrentTimeFunction;
161 static double s_timeElapsed; 164 static double s_timeElapsed;
162 }; 165 };
163 166
164 double CachingCorrectnessTest::s_timeElapsed; 167 double CachingCorrectnessTest::s_timeElapsed;
165 168
166 TEST_F(CachingCorrectnessTest, FreshFromLastModified) 169 TEST_F(CachingCorrectnessTest, FreshFromLastModified)
167 { 170 {
168 ResourceResponse fresh200Response; 171 ResourceResponse fresh200Response;
169 fresh200Response.setHTTPStatusCode(200); 172 fresh200Response.setHTTPStatusCode(200);
170 fresh200Response.setHTTPHeaderField("Date", kOriginalRequestDateAsString); 173 fresh200Response.setHTTPHeaderField("Date", kOriginalRequestDateAsString);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 firstResource->finish(); 564 firstResource->finish();
562 memoryCache()->add(firstResource); 565 memoryCache()->add(firstResource);
563 566
564 advanceClock(500.); 567 advanceClock(500.);
565 568
566 Resource* fetched = fetch(); 569 Resource* fetched = fetch();
567 EXPECT_EQ(firstResource, fetched); 570 EXPECT_EQ(firstResource, fetched);
568 } 571 }
569 572
570 } // namespace blink 573 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698