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

Unified Diff: Source/modules/serviceworkers/CacheTest.cpp

Issue 700323003: Use Web IDL Union types in Service Worker's Cache interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/serviceworkers/Cache.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/CacheTest.cpp
diff --git a/Source/modules/serviceworkers/CacheTest.cpp b/Source/modules/serviceworkers/CacheTest.cpp
index 0520a4e07a639e9da68878c752fb31e205774632..0f5c7926f2fa08f7e9f7644e362c0d987b4ae940 100644
--- a/Source/modules/serviceworkers/CacheTest.cpp
+++ b/Source/modules/serviceworkers/CacheTest.cpp
@@ -267,6 +267,20 @@ private:
NonThrowableExceptionState m_exceptionState;
};
+RequestInfo stringToRequestInfo(const String& value)
+{
+ RequestInfo info;
+ info.setUSVString(value);
+ return info;
+}
+
+RequestInfo requestToRequestInfo(Request* value)
+{
+ RequestInfo info;
+ info.setRequest(value);
+ return info;
+}
+
TEST_F(ServiceWorkerCacheTest, Basics)
{
ErrorWebCacheForTests* testCache;
@@ -276,16 +290,16 @@ TEST_F(ServiceWorkerCacheTest, Basics)
const String url = "http://www.cachetest.org/";
CacheQueryOptions options;
- ScriptPromise matchPromise = cache->match(scriptState(), url, options, exceptionState());
+ ScriptPromise matchPromise = cache->match(scriptState(), stringToRequestInfo(url), options, exceptionState());
EXPECT_EQ(kNotImplementedString, getRejectString(matchPromise));
cache = Cache::create(testCache = new ErrorWebCacheForTests(WebServiceWorkerCacheErrorNotFound));
- matchPromise = cache->match(scriptState(), url, options, exceptionState());
+ matchPromise = cache->match(scriptState(), stringToRequestInfo(url), options, exceptionState());
ScriptValue scriptValue = getResolveValue(matchPromise);
EXPECT_TRUE(scriptValue.isUndefined());
cache = Cache::create(testCache = new ErrorWebCacheForTests(WebServiceWorkerCacheErrorExists));
- matchPromise = cache->match(scriptState(), url, options, exceptionState());
+ matchPromise = cache->match(scriptState(), stringToRequestInfo(url), options, exceptionState());
EXPECT_EQ("InvalidAccessError: Entry already exists.", getRejectString(matchPromise));
}
@@ -311,35 +325,35 @@ TEST_F(ServiceWorkerCacheTest, BasicArguments)
Request* request = newRequestFromUrl(url);
ASSERT(request);
- ScriptPromise matchResult = cache->match(scriptState(), request, options);
+ ScriptPromise matchResult = cache->match(scriptState(), requestToRequestInfo(request), options, exceptionState());
EXPECT_EQ("dispatchMatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(matchResult));
- ScriptPromise stringMatchResult = cache->match(scriptState(), url, options, exceptionState());
+ ScriptPromise stringMatchResult = cache->match(scriptState(), stringToRequestInfo(url), options, exceptionState());
EXPECT_EQ("dispatchMatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringMatchResult));
request = newRequestFromUrl(url);
ASSERT(request);
- ScriptPromise matchAllResult = cache->matchAll(scriptState(), request, options);
+ ScriptPromise matchAllResult = cache->matchAll(scriptState(), requestToRequestInfo(request), options, exceptionState());
EXPECT_EQ("dispatchMatchAll", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(matchAllResult));
- ScriptPromise stringMatchAllResult = cache->matchAll(scriptState(), url, options, exceptionState());
+ ScriptPromise stringMatchAllResult = cache->matchAll(scriptState(), stringToRequestInfo(url), options, exceptionState());
EXPECT_EQ("dispatchMatchAll", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringMatchAllResult));
- ScriptPromise keysResult1 = cache->keys(scriptState());
+ ScriptPromise keysResult1 = cache->keys(scriptState(), exceptionState());
EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(keysResult1));
request = newRequestFromUrl(url);
ASSERT(request);
- ScriptPromise keysResult2 = cache->keys(scriptState(), request, options);
+ ScriptPromise keysResult2 = cache->keys(scriptState(), requestToRequestInfo(request), options, exceptionState());
EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(keysResult2));
- ScriptPromise stringKeysResult2 = cache->keys(scriptState(), url, options, exceptionState());
+ ScriptPromise stringKeysResult2 = cache->keys(scriptState(), stringToRequestInfo(url), options, exceptionState());
EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringKeysResult2));
}
@@ -378,11 +392,11 @@ TEST_F(ServiceWorkerCacheTest, BatchOperationArguments)
}
testCache->setExpectedBatchOperations(&expectedDeleteOperations);
- ScriptPromise deleteResult = cache->deleteFunction(scriptState(), request, options);
+ ScriptPromise deleteResult = cache->deleteFunction(scriptState(), requestToRequestInfo(request), options, exceptionState());
EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(deleteResult));
- ScriptPromise stringDeleteResult = cache->deleteFunction(scriptState(), url, options, exceptionState());
+ ScriptPromise stringDeleteResult = cache->deleteFunction(scriptState(), stringToRequestInfo(url), options, exceptionState());
EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringDeleteResult));
@@ -398,11 +412,11 @@ TEST_F(ServiceWorkerCacheTest, BatchOperationArguments)
request = newRequestFromUrl(url);
ASSERT(request);
- ScriptPromise putResult = cache->put(scriptState(), request, response);
+ ScriptPromise putResult = cache->put(scriptState(), requestToRequestInfo(request), response, exceptionState());
EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(putResult));
- ScriptPromise stringPutResult = cache->put(scriptState(), url, response, exceptionState());
+ ScriptPromise stringPutResult = cache->put(scriptState(), stringToRequestInfo(url), response, exceptionState());
EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringPutResult));
@@ -437,7 +451,7 @@ TEST_F(ServiceWorkerCacheTest, MatchResponseTest)
Cache* cache = Cache::create(new MatchTestCache(webResponse));
CacheQueryOptions options;
- ScriptPromise result = cache->match(scriptState(), requestUrl, options, exceptionState());
+ ScriptPromise result = cache->match(scriptState(), stringToRequestInfo(requestUrl), options, exceptionState());
ScriptValue scriptValue = getResolveValue(result);
Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue.v8Value());
ASSERT_TRUE(response);
@@ -474,7 +488,7 @@ TEST_F(ServiceWorkerCacheTest, KeysResponseTest)
Cache* cache = Cache::create(new KeysTestCache(webRequests));
- ScriptPromise result = cache->keys(scriptState());
+ ScriptPromise result = cache->keys(scriptState(), exceptionState());
ScriptValue scriptValue = getResolveValue(result);
Vector<v8::Handle<v8::Value> > requests = toImplArray<v8::Handle<v8::Value> >(scriptValue.v8Value(), 0, isolate(), exceptionState());
@@ -526,7 +540,7 @@ TEST_F(ServiceWorkerCacheTest, MatchAllAndBatchResponseTest)
Cache* cache = Cache::create(new MatchAllAndBatchTestCache(webResponses));
CacheQueryOptions options;
- ScriptPromise result = cache->matchAll(scriptState(), "http://some.url/", options, exceptionState());
+ ScriptPromise result = cache->matchAll(scriptState(), stringToRequestInfo("http://some.url/"), options, exceptionState());
ScriptValue scriptValue = getResolveValue(result);
Vector<v8::Handle<v8::Value> > responses = toImplArray<v8::Handle<v8::Value> >(scriptValue.v8Value(), 0, isolate(), exceptionState());
@@ -538,7 +552,7 @@ TEST_F(ServiceWorkerCacheTest, MatchAllAndBatchResponseTest)
EXPECT_EQ(expectedUrls[i], response->url());
}
- result = cache->deleteFunction(scriptState(), "http://some.url/", options, exceptionState());
+ result = cache->deleteFunction(scriptState(), stringToRequestInfo("http://some.url/"), options, exceptionState());
scriptValue = getResolveValue(result);
EXPECT_TRUE(scriptValue.v8Value()->IsBoolean());
EXPECT_EQ(true, scriptValue.v8Value()->BooleanValue());
« no previous file with comments | « Source/modules/serviceworkers/Cache.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698