OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright 2014, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
13 * distribution. | 13 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
17 * | 17 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 #include "core/html/HTMLLinkElement.h" |
33 #include "WebUserGestureToken.h" | |
34 | 33 |
35 #include <gtest/gtest.h> | 34 #include <gtest/gtest.h> |
36 #include "WebScopedUserGesture.h" | |
37 #include "WebUserGestureIndicator.h" | |
38 #include "platform/UserGestureIndicator.h" | |
39 | 35 |
40 using namespace blink; | |
41 using namespace WebCore; | 36 using namespace WebCore; |
42 | 37 |
43 namespace { | 38 namespace { |
44 | 39 |
45 TEST(WebUserGestureTokenTest, Basic) | 40 class HTMLLinkElementSizesAttributeTest : public testing::Test { |
| 41 }; |
| 42 |
| 43 TEST(HTMLLinkElementSizesAttributeTest, parseSizes) |
46 { | 44 { |
47 WebUserGestureToken token; | 45 AtomicString sizesAttribute = "32x33"; |
48 EXPECT_FALSE(token.hasGestures()); | 46 Vector<IntSize> sizes; |
| 47 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes); |
| 48 ASSERT_EQ(1U, sizes.size()); |
| 49 EXPECT_EQ(32, sizes[0].width()); |
| 50 EXPECT_EQ(33, sizes[0].height()); |
49 | 51 |
50 { | 52 sizesAttribute = "32x33 16x17 128x129"; |
51 WebScopedUserGesture indicator(token); | 53 sizes.clear(); |
52 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); | 54 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes); |
53 } | 55 ASSERT_EQ(3U, sizes.size()); |
| 56 EXPECT_EQ(32, sizes[0].width()); |
| 57 EXPECT_EQ(33, sizes[0].height()); |
| 58 EXPECT_EQ(16, sizes[1].width()); |
| 59 EXPECT_EQ(17, sizes[1].height()); |
| 60 EXPECT_EQ(128, sizes[2].width()); |
| 61 EXPECT_EQ(129, sizes[2].height()); |
54 | 62 |
55 { | 63 sizesAttribute = "any"; |
56 UserGestureIndicator indicator(DefinitelyProcessingNewUserGesture); | 64 sizes.clear(); |
57 EXPECT_TRUE(WebUserGestureIndicator::isProcessingUserGesture()); | 65 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes); |
58 token = WebUserGestureIndicator::currentUserGestureToken(); | 66 ASSERT_EQ(0U, sizes.size()); |
59 } | |
60 | 67 |
61 EXPECT_TRUE(token.hasGestures()); | 68 sizesAttribute = "32x33 32"; |
62 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); | 69 sizes.clear(); |
| 70 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes); |
| 71 ASSERT_EQ(0U, sizes.size()); |
63 | 72 |
64 { | 73 sizesAttribute = "32x33 any"; |
65 WebScopedUserGesture indicator(token); | 74 sizes.clear(); |
66 EXPECT_TRUE(WebUserGestureIndicator::isProcessingUserGesture()); | 75 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes); |
67 WebUserGestureIndicator::consumeUserGesture(); | 76 ASSERT_EQ(0U, sizes.size()); |
68 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); | |
69 } | |
70 | |
71 EXPECT_FALSE(token.hasGestures()); | |
72 | |
73 { | |
74 WebScopedUserGesture indicator(token); | |
75 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); | |
76 } | |
77 } | 77 } |
78 | 78 |
79 } | 79 } // namespace |
OLD | NEW |