MouseCursorMonitor implementation for OSX and Windows.

BUG=crbug.com/173265
R=wez@chromium.org

Review URL: https://webrtc-codereview.appspot.com/2388004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4994 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
sergeyu@chromium.org
2013-10-17 19:47:18 +00:00
parent 6b426ba5c5
commit 2df89c0c8b
12 changed files with 379 additions and 91 deletions

View File

@ -9,7 +9,9 @@
*/
#include "testing/gmock/include/gmock/gmock.h"
#include "webrtc/modules/desktop_capture/desktop_frame.h"
#include "webrtc/modules/desktop_capture/desktop_geometry.h"
#include "webrtc/modules/desktop_capture/mouse_cursor.h"
#include "webrtc/modules/desktop_capture/win/cursor.h"
#include "webrtc/modules/desktop_capture/win/cursor_unittest_resources.h"
#include "webrtc/modules/desktop_capture/win/scoped_gdi_object.h"
@ -19,9 +21,9 @@ namespace webrtc {
namespace {
// Loads |left| from resources, converts it to a |MouseCursorShape| instance
// and compares pixels with |right|. Returns true of MouseCursorShape bits
// match |right|. |right| must be a 32bpp cursor with alpha channel.
// Loads |left| from resources, converts it to a |MouseCursor| instance and
// compares pixels with |right|. Returns true of MouseCursor bits match |right|.
// |right| must be a 32bpp cursor with alpha channel.
bool ConvertToMouseShapeAndCompare(unsigned left, unsigned right) {
HMODULE instance = GetModuleHandle(NULL);
@ -32,8 +34,8 @@ bool ConvertToMouseShapeAndCompare(unsigned left, unsigned right) {
// Convert |cursor| to |mouse_shape|.
HDC dc = GetDC(NULL);
scoped_ptr<MouseCursorShape> mouse_shape(
CreateMouseCursorShapeFromCursor(dc, cursor));
scoped_ptr<MouseCursor> mouse_shape(
CreateMouseCursorFromHCursor(dc, cursor));
ReleaseDC(NULL, dc);
EXPECT_TRUE(mouse_shape.get());
@ -56,7 +58,7 @@ bool ConvertToMouseShapeAndCompare(unsigned left, unsigned right) {
int width = bitmap_info.bmWidth;
int height = bitmap_info.bmHeight;
EXPECT_TRUE(DesktopSize(width, height).equals(mouse_shape->size));
EXPECT_TRUE(DesktopSize(width, height).equals(mouse_shape->image().size()));
// Get the pixels from |scoped_color|.
int size = width * height;
@ -64,13 +66,13 @@ bool ConvertToMouseShapeAndCompare(unsigned left, unsigned right) {
EXPECT_TRUE(GetBitmapBits(scoped_color, size * sizeof(uint32_t), data.get()));
// Compare the 32bpp image in |mouse_shape| with the one loaded from |right|.
return memcmp(data.get(), mouse_shape->data.data(),
return memcmp(data.get(), mouse_shape->image().data(),
size * sizeof(uint32_t)) == 0;
}
} // namespace
TEST(MouseCursorShapeTest, MatchCursors) {
TEST(MouseCursorTest, MatchCursors) {
EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR1_24BPP,
IDD_CURSOR1_32BPP));