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

Unified Diff: webkit/glue/webcursor_unittest.cc

Issue 3244006: Merge 55669 - Clamp the hotspot on custom cursors to the custom cursor image'... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 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
« no previous file with comments | « webkit/glue/webcursor.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webcursor_unittest.cc
===================================================================
--- webkit/glue/webcursor_unittest.cc (revision 58015)
+++ webkit/glue/webcursor_unittest.cc (working copy)
@@ -4,9 +4,12 @@
#include "base/pickle.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
#include "webkit/glue/webcursor.h"
#include "webkit/tools/test_shell/test_shell_test.h"
+using WebKit::WebCursorInfo;
+
TEST(WebCursorTest, CursorSerialization) {
WebCursor custom_cursor;
// This is a valid custom cursor.
@@ -80,3 +83,36 @@
EXPECT_FALSE(custom_cursor.Deserialize(&neg_custom_pickle, &iter));
}
+TEST(WebCursorTest, ClampHotspot) {
+ WebCursor custom_cursor;
+ // This is a valid custom cursor.
+ Pickle ok_custom_pickle;
+ // Type and hotspots.
+ ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ // Hotspot is invalid --- outside the bounds of the image.
+ ok_custom_pickle.WriteInt(5);
+ ok_custom_pickle.WriteInt(5);
+ // X & Y
+ ok_custom_pickle.WriteInt(2);
+ ok_custom_pickle.WriteInt(2);
+ // Data len including enough data for a 2x2 image.
+ ok_custom_pickle.WriteInt(4 * 4);
+ for (size_t i = 0; i < 4; i++)
+ ok_custom_pickle.WriteUInt32(0);
+ // Custom Windows message.
+ ok_custom_pickle.WriteUInt32(0);
+ void* iter = NULL;
+ ASSERT_TRUE(custom_cursor.Deserialize(&ok_custom_pickle, &iter));
+
+ // Convert to WebCursorInfo, make sure the hotspot got clamped.
+ WebCursorInfo info;
+ custom_cursor.GetCursorInfo(&info);
+ EXPECT_EQ(gfx::Point(1, 1), gfx::Point(info.hotSpot));
+
+ // Set hotspot to an invalid point again, pipe back through WebCursor,
+ // and make sure the hotspot got clamped again.
+ info.hotSpot = gfx::Point(-1, -1);
+ custom_cursor.InitFromCursorInfo(info);
+ custom_cursor.GetCursorInfo(&info);
+ EXPECT_EQ(gfx::Point(0, 0), gfx::Point(info.hotSpot));
+}
« no previous file with comments | « webkit/glue/webcursor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698