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

Unified Diff: third_party/WebKit/LayoutTests/presentation/presentationconnectionavailableevent-ctor-mock.html

Issue 2491693003: Add tests for PresentationConnectionAvailable constructor. (Closed)
Patch Set: review comments Created 4 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
Index: third_party/WebKit/LayoutTests/presentation/presentationconnectionavailableevent-ctor-mock.html
diff --git a/third_party/WebKit/LayoutTests/presentation/presentationconnectionavailableevent-ctor-mock.html b/third_party/WebKit/LayoutTests/presentation/presentationconnectionavailableevent-ctor-mock.html
new file mode 100644
index 0000000000000000000000000000000000000000..a9fc9430506dcffda53431778149e3977e613a72
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/presentation/presentationconnectionavailableevent-ctor-mock.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/mojo-helpers.js"></script>
+<script src="resources/presentation-service-mock.js"></script>
+<button>click me</button>
+<script>
+
+function waitForClick(callback) {
+ var button = document.querySelector('button');
+ button.addEventListener('click', callback, { once: true });
+
+ if (!('eventSender' in window))
+ return;
+
+ var boundingRect = button.getBoundingClientRect();
+ var x = boundingRect.left + boundingRect.width / 2;
+ var y = boundingRect.top + boundingRect.height / 2;
+
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+async_test(t => {
+ presentationServiceMock.then(t.step_func(mockService => {
+ // This is receiving the user gesture and runs the callback.
+ waitForClick(t.step_func(_ => {
+ new PresentationRequest('https://example.com').start().then(
+ t.step_func_done(result => {
+ var e = new PresentationConnectionAvailableEvent(
+ 'connectionavailable', { connection: result });
+ assert_not_equals(e, null);
+ assert_equals(e.connection, result);
+ }));
+ }));
+ }));
+}, "Test that the PresentationConnectionAvailableEvent ctor can take a valid PresentationConnection.")
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698