| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/pickle.h" | 5 #include "base/pickle.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 7 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| 8 #include "webkit/common/cursors/webcursor.h" | 8 #include "webkit/common/cursors/webcursor.h" |
| 9 | 9 |
| 10 using blink::WebCursorInfo; | 10 using blink::WebCursorInfo; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 scale_tiny_custom_pickle.WriteFloat(0.001f); | 127 scale_tiny_custom_pickle.WriteFloat(0.001f); |
| 128 // Data len including enough data for a 1x1 image. | 128 // Data len including enough data for a 1x1 image. |
| 129 scale_tiny_custom_pickle.WriteInt(4); | 129 scale_tiny_custom_pickle.WriteInt(4); |
| 130 scale_tiny_custom_pickle.WriteUInt32(0); | 130 scale_tiny_custom_pickle.WriteUInt32(0); |
| 131 // Custom Windows message. | 131 // Custom Windows message. |
| 132 scale_tiny_custom_pickle.WriteUInt32(0); | 132 scale_tiny_custom_pickle.WriteUInt32(0); |
| 133 iter = PickleIterator(scale_tiny_custom_pickle); | 133 iter = PickleIterator(scale_tiny_custom_pickle); |
| 134 EXPECT_FALSE(custom_cursor.Deserialize(&iter)); | 134 EXPECT_FALSE(custom_cursor.Deserialize(&iter)); |
| 135 } | 135 } |
| 136 | 136 |
| 137 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 138 TEST(WebCursorTest, WindowsCursorConversion) { | |
| 139 WebCursor custom_cursor; | |
| 140 Pickle win32_custom_pickle; | |
| 141 WebCursor win32_custom_cursor; | |
| 142 win32_custom_cursor.InitFromExternalCursor( | |
| 143 reinterpret_cast<HCURSOR>(1000)); | |
| 144 EXPECT_TRUE(win32_custom_cursor.Serialize(&win32_custom_pickle)); | |
| 145 PickleIterator iter(win32_custom_pickle); | |
| 146 EXPECT_TRUE(custom_cursor.Deserialize(&iter)); | |
| 147 EXPECT_EQ(reinterpret_cast<HCURSOR>(1000), custom_cursor.GetCursor(NULL)); | |
| 148 } | |
| 149 #endif // OS_WIN | |
| 150 | |
| 151 TEST(WebCursorTest, ClampHotspot) { | 137 TEST(WebCursorTest, ClampHotspot) { |
| 152 WebCursor custom_cursor; | 138 WebCursor custom_cursor; |
| 153 // This is a valid custom cursor. | 139 // This is a valid custom cursor. |
| 154 Pickle ok_custom_pickle; | 140 Pickle ok_custom_pickle; |
| 155 // Type and hotspots. | 141 // Type and hotspots. |
| 156 ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom); | 142 ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom); |
| 157 // Hotspot is invalid --- outside the bounds of the image. | 143 // Hotspot is invalid --- outside the bounds of the image. |
| 158 ok_custom_pickle.WriteInt(5); | 144 ok_custom_pickle.WriteInt(5); |
| 159 ok_custom_pickle.WriteInt(5); | 145 ok_custom_pickle.WriteInt(5); |
| 160 // X & Y | 146 // X & Y |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 PickleIterator iter(ok_custom_pickle); | 221 PickleIterator iter(ok_custom_pickle); |
| 236 EXPECT_TRUE(custom_cursor.Deserialize(&iter)); | 222 EXPECT_TRUE(custom_cursor.Deserialize(&iter)); |
| 237 | 223 |
| 238 #if defined(TOOLKIT_GTK) | 224 #if defined(TOOLKIT_GTK) |
| 239 // On GTK+ using platforms, we should get a real native GdkCursor object back | 225 // On GTK+ using platforms, we should get a real native GdkCursor object back |
| 240 // (and the memory used should automatically be freed by the WebCursor object | 226 // (and the memory used should automatically be freed by the WebCursor object |
| 241 // for valgrind tests). | 227 // for valgrind tests). |
| 242 EXPECT_TRUE(custom_cursor.GetCustomCursor()); | 228 EXPECT_TRUE(custom_cursor.GetCustomCursor()); |
| 243 #endif | 229 #endif |
| 244 } | 230 } |
| OLD | NEW |