Index: third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp |
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp b/third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3dce79b5d6ed5a837975d2741f712b54e649f27b |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp |
@@ -0,0 +1,56 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "modules/presentation/PresentationRequest.h" |
+ |
+#include "bindings/core/v8/V8BindingForTesting.h" |
+#include "core/dom/ExceptionCode.h" |
+#include "platform/weborigin/KURL.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace blink { |
+namespace { |
+ |
+TEST(PresentationRequestTest, TestSingleUrlConstructor) |
+{ |
+ V8TestingScope scope; |
+ PresentationRequest* request = PresentationRequest::create(scope.getExecutionContext(), "https://example.com", scope.getExceptionState()); |
+ ASSERT_FALSE(scope.getExceptionState().hadException()); |
+ WTF::Vector<KURL> requestUrls = request->urls(); |
+ EXPECT_EQ(requestUrls.size(), static_cast<size_t>(1)); |
+ EXPECT_TRUE(requestUrls[0].isValid()); |
+ EXPECT_EQ(requestUrls[0].getString(), "https://example.com/"); |
+} |
+ |
+TEST(PresentationRequestTest, TestMultipleUrlConstructor) |
+{ |
+ V8TestingScope scope; |
+ WTF::Vector<String> urls; |
+ urls.append("https://example.com"); |
+ urls.append("cast://google.com/appid=deadbeef"); |
mlamouri (slow - plz ping)
2016/07/19 12:45:03
I'm genuinely surprised this is a valid URL :) I w
mark a. foltz
2016/07/19 17:38:47
Changed to cast:://deadbeef?param=foo and the test
|
+ |
+ PresentationRequest* request = PresentationRequest::create(scope.getExecutionContext(), urls, scope.getExceptionState()); |
+ ASSERT_FALSE(scope.getExceptionState().hadException()); |
+ WTF::Vector<KURL> requestUrls = request->urls(); |
+ EXPECT_EQ(static_cast<size_t>(2), requestUrls.size()); |
+ EXPECT_TRUE(requestUrls[0].isValid()); |
+ EXPECT_EQ("https://example.com/", requestUrls[0].getString()); |
+ EXPECT_TRUE(requestUrls[1].isValid()); |
+ EXPECT_EQ("cast://google.com/appid=deadbeef", requestUrls[1].getString()); |
+} |
+ |
+TEST(PresentationRequestTest, TestMultipleUrlConstructorInvalidUrl) |
+{ |
+ V8TestingScope scope; |
+ WTF::Vector<String> urls; |
+ urls.append("https://example.com"); |
+ urls.append(""); |
+ |
+ PresentationRequest::create(scope.getExecutionContext(), urls, scope.getExceptionState()); |
+ EXPECT_TRUE(scope.getExceptionState().hadException()); |
+ EXPECT_EQ(V8TypeError, scope.getExceptionState().code()); |
+} |
+ |
+} // anonymous namespace |
+} // namespace blink |