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

Side by Side Diff: third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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 // 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 #include "modules/cachestorage/Cache.h" 5 #include "modules/cachestorage/Cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include "bindings/core/v8/ExceptionState.h" 10 #include "bindings/core/v8/ExceptionState.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 if (m_response) { 60 if (m_response) {
61 ScriptPromiseResolver* resolver = 61 ScriptPromiseResolver* resolver =
62 ScriptPromiseResolver::create(scriptState); 62 ScriptPromiseResolver::create(scriptState);
63 const ScriptPromise promise = resolver->promise(); 63 const ScriptPromise promise = resolver->promise();
64 resolver->resolve(m_response); 64 resolver->resolve(m_response);
65 m_response = nullptr; 65 m_response = nullptr;
66 return promise; 66 return promise;
67 } 67 }
68 return ScriptPromise::reject( 68 return ScriptPromise::reject(
69 scriptState, V8ThrowException::createTypeError( 69 scriptState,
70 scriptState->isolate(), 70 V8ThrowException::createTypeError(
71 "Unexpected call to fetch, no response available.")); 71 scriptState->isolate(),
72 "Unexpected call to fetch, no response available."));
72 } 73 }
73 74
74 // This does not take ownership of its parameter. The provided sample object 75 // This does not take ownership of its parameter. The provided sample object
75 // is used to check the parameter when called. 76 // is used to check the parameter when called.
76 void setExpectedFetchUrl(const String* expectedUrl) { 77 void setExpectedFetchUrl(const String* expectedUrl) {
77 m_expectedUrl = expectedUrl; 78 m_expectedUrl = expectedUrl;
78 } 79 }
79 void setResponse(Response* response) { m_response = response; } 80 void setResponse(Response* response) { m_response = response; }
80 81
81 int fetchCount() const { return m_fetchCount; } 82 int fetchCount() const { return m_fetchCount; }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 CompareQueryParamsForTest(*m_expectedQueryParams, queryParams); 180 CompareQueryParamsForTest(*m_expectedQueryParams, queryParams);
180 } 181 }
181 182
182 void checkBatchOperationsIfProvided( 183 void checkBatchOperationsIfProvided(
183 const WebVector<BatchOperation>& batchOperations) { 184 const WebVector<BatchOperation>& batchOperations) {
184 if (!m_expectedBatchOperations) 185 if (!m_expectedBatchOperations)
185 return; 186 return;
186 const WebVector<BatchOperation> expectedBatchOperations = 187 const WebVector<BatchOperation> expectedBatchOperations =
187 *m_expectedBatchOperations; 188 *m_expectedBatchOperations;
188 EXPECT_EQ(expectedBatchOperations.size(), batchOperations.size()); 189 EXPECT_EQ(expectedBatchOperations.size(), batchOperations.size());
189 for (int i = 0, minsize = std::min(expectedBatchOperations.size(), 190 for (int i = 0,
190 batchOperations.size()); 191 minsize = std::min(expectedBatchOperations.size(),
192 batchOperations.size());
191 i < minsize; ++i) { 193 i < minsize; ++i) {
192 EXPECT_EQ(expectedBatchOperations[i].operationType, 194 EXPECT_EQ(expectedBatchOperations[i].operationType,
193 batchOperations[i].operationType); 195 batchOperations[i].operationType);
194 const String expectedRequestUrl = 196 const String expectedRequestUrl =
195 KURL(expectedBatchOperations[i].request.url()); 197 KURL(expectedBatchOperations[i].request.url());
196 EXPECT_EQ(expectedRequestUrl, KURL(batchOperations[i].request.url())); 198 EXPECT_EQ(expectedRequestUrl, KURL(batchOperations[i].request.url()));
197 ASSERT_EQ(expectedBatchOperations[i].response.urlList().size(), 199 ASSERT_EQ(expectedBatchOperations[i].response.urlList().size(),
198 batchOperations[i].response.urlList().size()); 200 batchOperations[i].response.urlList().size());
199 for (size_t j = 0; 201 for (size_t j = 0;
200 j < expectedBatchOperations[i].response.urlList().size(); ++j) { 202 j < expectedBatchOperations[i].response.urlList().size(); ++j) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 createCache(fetcher, testCache = new NotImplementedErrorCache()); 357 createCache(fetcher, testCache = new NotImplementedErrorCache());
356 ASSERT(cache); 358 ASSERT(cache);
357 359
358 const String url = "http://www.cachetest.org/"; 360 const String url = "http://www.cachetest.org/";
359 361
360 CacheQueryOptions options; 362 CacheQueryOptions options;
361 ScriptPromise matchPromise = cache->match( 363 ScriptPromise matchPromise = cache->match(
362 getScriptState(), stringToRequestInfo(url), options, exceptionState); 364 getScriptState(), stringToRequestInfo(url), options, exceptionState);
363 EXPECT_EQ(kNotImplementedString, getRejectString(matchPromise)); 365 EXPECT_EQ(kNotImplementedString, getRejectString(matchPromise));
364 366
365 cache = createCache(fetcher, testCache = new ErrorWebCacheForTests( 367 cache = createCache(fetcher,
366 WebServiceWorkerCacheErrorNotFound)); 368 testCache = new ErrorWebCacheForTests(
369 WebServiceWorkerCacheErrorNotFound));
367 matchPromise = cache->match(getScriptState(), stringToRequestInfo(url), 370 matchPromise = cache->match(getScriptState(), stringToRequestInfo(url),
368 options, exceptionState); 371 options, exceptionState);
369 ScriptValue scriptValue = getResolveValue(matchPromise); 372 ScriptValue scriptValue = getResolveValue(matchPromise);
370 EXPECT_TRUE(scriptValue.isUndefined()); 373 EXPECT_TRUE(scriptValue.isUndefined());
371 374
372 cache = createCache(fetcher, testCache = new ErrorWebCacheForTests( 375 cache = createCache(
373 WebServiceWorkerCacheErrorExists)); 376 fetcher,
377 testCache = new ErrorWebCacheForTests(WebServiceWorkerCacheErrorExists));
374 matchPromise = cache->match(getScriptState(), stringToRequestInfo(url), 378 matchPromise = cache->match(getScriptState(), stringToRequestInfo(url),
375 options, exceptionState); 379 options, exceptionState);
376 EXPECT_EQ("InvalidAccessError: Entry already exists.", 380 EXPECT_EQ("InvalidAccessError: Entry already exists.",
377 getRejectString(matchPromise)); 381 getRejectString(matchPromise));
378 } 382 }
379 383
380 // Tests that arguments are faithfully passed on calls to Cache methods, except 384 // Tests that arguments are faithfully passed on calls to Cache methods, except
381 // for methods which use batch operations, which are tested later. 385 // for methods which use batch operations, which are tested later.
382 TEST_F(CacheStorageTest, BasicArguments) { 386 TEST_F(CacheStorageTest, BasicArguments) {
383 ScriptState::Scope scope(getScriptState()); 387 ScriptState::Scope scope(getScriptState());
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 727
724 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); 728 EXPECT_EQ(kNotImplementedString, getRejectString(addResult));
725 EXPECT_EQ(1, fetcher->fetchCount()); 729 EXPECT_EQ(1, fetcher->fetchCount());
726 EXPECT_EQ("dispatchBatch", 730 EXPECT_EQ("dispatchBatch",
727 testCache->getAndClearLastErrorWebCacheMethodCalled()); 731 testCache->getAndClearLastErrorWebCacheMethodCalled());
728 } 732 }
729 733
730 } // namespace 734 } // namespace
731 735
732 } // namespace blink 736 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698