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

Unified Diff: LayoutTests/fast/events/touch/resources/touch-hover-active-tests.js

Issue 197923006: Refactor touch hit-testing hover/active tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/events/touch/resources/touch-hover-active-tests.js
diff --git a/LayoutTests/fast/events/touch/resources/touch-hover-active-tests.js b/LayoutTests/fast/events/touch/resources/touch-hover-active-tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..8718a22dc1907ed58cb7374188427a06af9906b5
--- /dev/null
+++ b/LayoutTests/fast/events/touch/resources/touch-hover-active-tests.js
@@ -0,0 +1,35 @@
+function getElement(e)
+{
+ if (typeof e == "string")
+ e = document.getElementById(e);
+ return e;
+}
+
+function isBoxOfColor(givenColor)
+{
+ return function(e, quiet)
+ {
+ e = getElement(e);
+ var color = window.getComputedStyle(e).backgroundColor;
+ if (color == givenColor)
+ return true;
+ if (!quiet)
+ testFailed('Box had backgroundColor: ' + color);
+ return false;
+ }
+}
+
+function elementCenter(e)
tdresser 2014/03/14 14:24:51 Where is this used?
Zeeshan Qureshi 2014/03/14 14:52:21 Oh I was using this in another CL and decided to s
+{
+ e = getElement(e);
+ return {
+ x: e.offsetLeft + e.offsetWidth / 2,
+ y: e.offsetTop + e.offsetHeight / 2
+ }
+}
+
+// Generate methods
tdresser 2014/03/14 14:24:51 Could switch to "boxShouldBeOfColor," which would
Zeeshan Qureshi 2014/03/14 14:52:21 I'm not quite following this, wouldn't the test ou
+window.isBoxDefault = isBoxOfColor("rgb(0, 0, 255)");
+window.isBoxHovered = isBoxOfColor("rgb(255, 0, 0)");
+window.isBoxActive = isBoxOfColor("rgb(0, 255, 0)");
+window.isBoxHoverActive = isBoxOfColor("rgb(255, 255, 0)");
tdresser 2014/03/14 14:24:51 How about "isBoxHoveredAndActive"?
Zeeshan Qureshi 2014/03/14 14:52:21 That sounds better.

Powered by Google App Engine
This is Rietveld 408576698