aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/style/cursor_test.html
blob: 6e2a311154f65e724d5febb339484525d4acf481 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<!--
Copyright 2009 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<!--
  Author: dgajda@google.com (Damian Gajda)
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.style.cursor</title>
<script src="../base.js"></script>
<script>
  goog.require('goog.testing.jsunit');

  goog.require('goog.style.cursor');
  goog.require('goog.userAgent');
</script>
</head>
<body>
<script>

var baseCursorUrl = '/images/2/';
var origWindowsUserAgentValue;
var origGeckoUserAgentValue;
var origWebkitUserAgentValue;


function setUp() {
  origWindowsUserAgentValue = goog.userAgent.WINDOWS;
  origGeckoUserAgentValue = goog.userAgent.GECKO;
  origWebkitUserAgentValue = goog.userAgent.WEBKIT;
}


function tearDown() {
  goog.userAgent.WINDOWS = origWindowsUserAgentValue;
  goog.userAgent.GECKO = origGeckoUserAgentValue;
  goog.userAgent.WEBKIT = origWebkitUserAgentValue;
}


function testGetCursorStylesWebkit() {
  goog.userAgent.GECKO = false;
  goog.userAgent.WEBKIT = true;

  assertEquals('Webkit should get a cursor style with moved hot-spot.',
      'url("/images/2/openhand.cur") 7 5, default',
      goog.style.cursor.getDraggableCursorStyle(baseCursorUrl));
  assertEquals('Webkit should get a cursor style with moved hot-spot.',
      'url("/images/2/openhand.cur") 7 5, default',
      goog.style.cursor.getDraggableCursorStyle(baseCursorUrl, true));

  assertEquals('Webkit should get a cursor style with moved hot-spot.',
      'url("/images/2/closedhand.cur") 7 5, move',
      goog.style.cursor.getDraggingCursorStyle(baseCursorUrl));
  assertEquals('Webkit should get a cursor style with moved hot-spot.',
      'url("/images/2/closedhand.cur") 7 5, move',
      goog.style.cursor.getDraggingCursorStyle(baseCursorUrl, true));
}


function testGetCursorStylesFireFoxNonWin() {
  goog.userAgent.GECKO = true;
  goog.userAgent.WEBKIT = false;
  goog.userAgent.WINDOWS = false;

  assertEquals('FireFox on non Windows should get a custom cursor style.',
      '-moz-grab',
      goog.style.cursor.getDraggableCursorStyle(baseCursorUrl));
  assertEquals('FireFox on non Windows should get a custom cursor style and ' +
      'no !important modifier.',
      '-moz-grab',
      goog.style.cursor.getDraggableCursorStyle(baseCursorUrl, true));

  assertEquals('FireFox on non Windows should get a custom cursor style.',
      '-moz-grabbing',
      goog.style.cursor.getDraggingCursorStyle(baseCursorUrl));
  assertEquals('FireFox on non Windows should get a custom cursor style and ' +
          'no !important modifier.',
      '-moz-grabbing',
      goog.style.cursor.getDraggingCursorStyle(baseCursorUrl, true));
}


function testGetCursorStylesFireFoxWin() {
  goog.userAgent.GECKO = true;
  goog.userAgent.WEBKIT = false;
  goog.userAgent.WINDOWS = true;

  assertEquals('FireFox should get a cursor style with URL.',
      'url("/images/2/openhand.cur"), default',
      goog.style.cursor.getDraggableCursorStyle(baseCursorUrl));
  assertEquals('FireFox should get a cursor style with URL and no !important' +
          ' modifier.',
      'url("/images/2/openhand.cur"), default',
      goog.style.cursor.getDraggableCursorStyle(baseCursorUrl, true));

  assertEquals('FireFox should get a cursor style with URL.',
      'url("/images/2/closedhand.cur"), move',
      goog.style.cursor.getDraggingCursorStyle(baseCursorUrl));
  assertEquals('FireFox should get a cursor style with URL and no !important' +
          ' modifier.',
      'url("/images/2/closedhand.cur"), move',
      goog.style.cursor.getDraggingCursorStyle(baseCursorUrl, true));
}


function testGetCursorStylesOther() {
  goog.userAgent.GECKO = false;
  goog.userAgent.WEBKIT = false;

  assertEquals('Other browsers (IE) should get a cursor style with URL.',
      'url("/images/2/openhand.cur"), default',
      goog.style.cursor.getDraggableCursorStyle(baseCursorUrl));
  assertEquals('Other browsers (IE) should get a cursor style with URL.',
      'url("/images/2/openhand.cur"), default',
      goog.style.cursor.getDraggableCursorStyle(baseCursorUrl, true));

  assertEquals('Other browsers (IE) should get a cursor style with URL.',
      'url("/images/2/closedhand.cur"), move',
      goog.style.cursor.getDraggingCursorStyle(baseCursorUrl));
  assertEquals('Other browsers (IE) should get a cursor style with URL.',
      'url("/images/2/closedhand.cur"), move',
      goog.style.cursor.getDraggingCursorStyle(baseCursorUrl, true));
}
</script>
</body>
</html>