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

Side by Side Diff: ui/display/win/screen_win_unittest.cc

Issue 2267123002: Scale Rect Origins Using the Specified HWND's Display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « ui/display/win/screen_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/display/win/screen_win.h" 5 #include "ui/display/win/screen_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <inttypes.h> 8 #include <inttypes.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 gfx::Rect left_origin(0, 0, 50, 100); 960 gfx::Rect left_origin(0, 0, 50, 100);
961 gfx::Rect left_middle(253, 495, 41, 52); 961 gfx::Rect left_middle(253, 495, 41, 52);
962 EXPECT_EQ(left_origin, ScreenWin::ScreenToDIPRect(left_hwnd, left_origin)); 962 EXPECT_EQ(left_origin, ScreenWin::ScreenToDIPRect(left_hwnd, left_origin));
963 EXPECT_EQ(left_middle, ScreenWin::ScreenToDIPRect(left_hwnd, left_middle)); 963 EXPECT_EQ(left_middle, ScreenWin::ScreenToDIPRect(left_hwnd, left_middle));
964 964
965 HWND right_hwnd = GetRightFakeHwnd(); 965 HWND right_hwnd = GetRightFakeHwnd();
966 gfx::Rect right_origin(1920, 0, 200, 300); 966 gfx::Rect right_origin(1920, 0, 200, 300);
967 gfx::Rect right_middle(2000, 496, 100, 200); 967 gfx::Rect right_middle(2000, 496, 100, 200);
968 EXPECT_EQ(right_origin, ScreenWin::ScreenToDIPRect(right_hwnd, right_origin)); 968 EXPECT_EQ(right_origin, ScreenWin::ScreenToDIPRect(right_hwnd, right_origin));
969 EXPECT_EQ(right_middle, ScreenWin::ScreenToDIPRect(right_hwnd, right_middle)); 969 EXPECT_EQ(right_middle, ScreenWin::ScreenToDIPRect(right_hwnd, right_middle));
970
971 gfx::Rect right_origin_left(1900, 200, 100, 100);
972 EXPECT_EQ(right_origin_left,
973 ScreenWin::ScreenToDIPRect(right_hwnd, right_origin_left));
970 } 974 }
971 975
972 TEST_F(ScreenWinTestTwoDisplays1x, DIPToScreenRects) { 976 TEST_F(ScreenWinTestTwoDisplays1x, DIPToScreenRects) {
973 HWND left_hwnd = GetLeftFakeHwnd(); 977 HWND left_hwnd = GetLeftFakeHwnd();
974 gfx::Rect left_origin(0, 0, 50, 100); 978 gfx::Rect left_origin(0, 0, 50, 100);
975 gfx::Rect left_middle(253, 495, 41, 52); 979 gfx::Rect left_middle(253, 495, 41, 52);
976 EXPECT_EQ(left_origin, ScreenWin::DIPToScreenRect(left_hwnd, left_origin)); 980 EXPECT_EQ(left_origin, ScreenWin::DIPToScreenRect(left_hwnd, left_origin));
977 EXPECT_EQ(left_middle, ScreenWin::DIPToScreenRect(left_hwnd, left_middle)); 981 EXPECT_EQ(left_middle, ScreenWin::DIPToScreenRect(left_hwnd, left_middle));
978 982
979 HWND right_hwnd = GetRightFakeHwnd(); 983 HWND right_hwnd = GetRightFakeHwnd();
980 gfx::Rect right_origin(1920, 0, 200, 300); 984 gfx::Rect right_origin(1920, 0, 200, 300);
981 gfx::Rect right_middle(2000, 496, 100, 200); 985 gfx::Rect right_middle(2000, 496, 100, 200);
982 EXPECT_EQ(right_origin, ScreenWin::DIPToScreenRect(right_hwnd, right_origin)); 986 EXPECT_EQ(right_origin, ScreenWin::DIPToScreenRect(right_hwnd, right_origin));
983 EXPECT_EQ(right_middle, ScreenWin::DIPToScreenRect(right_hwnd, right_middle)); 987 EXPECT_EQ(right_middle, ScreenWin::DIPToScreenRect(right_hwnd, right_middle));
988
989 gfx::Rect right_origin_left(1900, 200, 100, 100);
990 EXPECT_EQ(right_origin_left,
991 ScreenWin::DIPToScreenRect(right_hwnd, right_origin_left));
984 } 992 }
985 993
986 TEST_F(ScreenWinTestTwoDisplays1x, ClientToDIPRects) { 994 TEST_F(ScreenWinTestTwoDisplays1x, ClientToDIPRects) {
987 HWND left_hwnd = GetLeftFakeHwnd(); 995 HWND left_hwnd = GetLeftFakeHwnd();
988 gfx::Rect origin(0, 0, 50, 100); 996 gfx::Rect origin(0, 0, 50, 100);
989 gfx::Rect middle(253, 495, 41, 52); 997 gfx::Rect middle(253, 495, 41, 52);
990 EXPECT_EQ(origin, ScreenWin::ClientToDIPRect(left_hwnd, origin)); 998 EXPECT_EQ(origin, ScreenWin::ClientToDIPRect(left_hwnd, origin));
991 EXPECT_EQ(middle, ScreenWin::ClientToDIPRect(left_hwnd, middle)); 999 EXPECT_EQ(middle, ScreenWin::ClientToDIPRect(left_hwnd, middle));
992 1000
993 HWND right_hwnd = GetRightFakeHwnd(); 1001 HWND right_hwnd = GetRightFakeHwnd();
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 EXPECT_EQ(gfx::Rect(126, 248, 21, 26), 1234 EXPECT_EQ(gfx::Rect(126, 248, 21, 26),
1227 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 1235 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
1228 1236
1229 HWND right_hwnd = GetRightFakeHwnd(); 1237 HWND right_hwnd = GetRightFakeHwnd();
1230 EXPECT_EQ(gfx::Rect(960, 0, 100, 150), 1238 EXPECT_EQ(gfx::Rect(960, 0, 100, 150),
1231 ScreenWin::ScreenToDIPRect(right_hwnd, 1239 ScreenWin::ScreenToDIPRect(right_hwnd,
1232 gfx::Rect(1920, 0, 200, 300))); 1240 gfx::Rect(1920, 0, 200, 300)));
1233 EXPECT_EQ(gfx::Rect(1000, 248, 50, 100), 1241 EXPECT_EQ(gfx::Rect(1000, 248, 50, 100),
1234 ScreenWin::ScreenToDIPRect(right_hwnd, 1242 ScreenWin::ScreenToDIPRect(right_hwnd,
1235 gfx::Rect(2000, 496, 100, 200))); 1243 gfx::Rect(2000, 496, 100, 200)));
1244
1245 EXPECT_EQ(gfx::Rect(950, 100, 50, 50),
1246 ScreenWin::ScreenToDIPRect(right_hwnd,
1247 gfx::Rect(1900, 200, 100, 100)));
1236 } 1248 }
1237 1249
1238 TEST_F(ScreenWinTestTwoDisplays2x, DIPToScreenRects) { 1250 TEST_F(ScreenWinTestTwoDisplays2x, DIPToScreenRects) {
1239 HWND left_hwnd = GetLeftFakeHwnd(); 1251 HWND left_hwnd = GetLeftFakeHwnd();
1240 EXPECT_EQ(gfx::Rect(0, 0, 50, 100), 1252 EXPECT_EQ(gfx::Rect(0, 0, 50, 100),
1241 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 25, 50))); 1253 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 25, 50)));
1242 EXPECT_EQ(gfx::Rect(252, 496, 42, 52), 1254 EXPECT_EQ(gfx::Rect(252, 496, 42, 52),
1243 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(126, 248, 21, 26))); 1255 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(126, 248, 21, 26)));
1244 1256
1245 HWND right_hwnd = GetRightFakeHwnd(); 1257 HWND right_hwnd = GetRightFakeHwnd();
1246 EXPECT_EQ(gfx::Rect(1920, 0, 200, 300), 1258 EXPECT_EQ(gfx::Rect(1920, 0, 200, 300),
1247 ScreenWin::DIPToScreenRect(right_hwnd, 1259 ScreenWin::DIPToScreenRect(right_hwnd,
1248 gfx::Rect(960, 0, 100, 150))); 1260 gfx::Rect(960, 0, 100, 150)));
1249 EXPECT_EQ(gfx::Rect(2000, 496, 100, 200), 1261 EXPECT_EQ(gfx::Rect(2000, 496, 100, 200),
1250 ScreenWin::DIPToScreenRect(right_hwnd, 1262 ScreenWin::DIPToScreenRect(right_hwnd,
1251 gfx::Rect(1000, 248, 50, 100))); 1263 gfx::Rect(1000, 248, 50, 100)));
1264
1265 EXPECT_EQ(gfx::Rect(1900, 200, 100, 100),
1266 ScreenWin::DIPToScreenRect(right_hwnd,
1267 gfx::Rect(950, 100, 50, 50)));
1252 } 1268 }
1253 1269
1254 TEST_F(ScreenWinTestTwoDisplays2x, ClientToDIPRects) { 1270 TEST_F(ScreenWinTestTwoDisplays2x, ClientToDIPRects) {
1255 HWND left_hwnd = GetLeftFakeHwnd(); 1271 HWND left_hwnd = GetLeftFakeHwnd();
1256 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), 1272 EXPECT_EQ(gfx::Rect(0, 0, 25, 50),
1257 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); 1273 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100)));
1258 EXPECT_EQ(gfx::Rect(126, 248, 21, 26), 1274 EXPECT_EQ(gfx::Rect(126, 248, 21, 26),
1259 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 1275 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
1260 1276
1261 HWND right_hwnd = GetRightFakeHwnd(); 1277 HWND right_hwnd = GetRightFakeHwnd();
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
2336 EXPECT_EQ(gfx::Rect(253, 496, 41, 52), 2352 EXPECT_EQ(gfx::Rect(253, 496, 41, 52),
2337 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 2353 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
2338 2354
2339 HWND right_hwnd = GetRightFakeHwnd(); 2355 HWND right_hwnd = GetRightFakeHwnd();
2340 EXPECT_EQ(gfx::Rect(1920, 0, 100, 150), 2356 EXPECT_EQ(gfx::Rect(1920, 0, 100, 150),
2341 ScreenWin::ScreenToDIPRect(right_hwnd, 2357 ScreenWin::ScreenToDIPRect(right_hwnd,
2342 gfx::Rect(1920, 0, 200, 300))); 2358 gfx::Rect(1920, 0, 200, 300)));
2343 EXPECT_EQ(gfx::Rect(1960, 248, 50, 100), 2359 EXPECT_EQ(gfx::Rect(1960, 248, 50, 100),
2344 ScreenWin::ScreenToDIPRect(right_hwnd, 2360 ScreenWin::ScreenToDIPRect(right_hwnd,
2345 gfx::Rect(2000, 496, 100, 200))); 2361 gfx::Rect(2000, 496, 100, 200)));
2362
2363 EXPECT_EQ(gfx::Rect(1910, 100, 50, 50),
2364 ScreenWin::ScreenToDIPRect(right_hwnd,
2365 gfx::Rect(1900, 200, 100, 100)));
2346 } 2366 }
2347 2367
2348 TEST_F(ScreenWinTestTwoDisplays1x2x, DIPToScreenRects) { 2368 TEST_F(ScreenWinTestTwoDisplays1x2x, DIPToScreenRects) {
2349 HWND left_hwnd = GetLeftFakeHwnd(); 2369 HWND left_hwnd = GetLeftFakeHwnd();
2350 EXPECT_EQ(gfx::Rect(0, 0, 50, 100), 2370 EXPECT_EQ(gfx::Rect(0, 0, 50, 100),
2351 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); 2371 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 50, 100)));
2352 EXPECT_EQ(gfx::Rect(252, 496, 42, 52), 2372 EXPECT_EQ(gfx::Rect(252, 496, 42, 52),
2353 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(252, 496, 42, 52))); 2373 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(252, 496, 42, 52)));
2354 2374
2355 HWND right_hwnd = GetRightFakeHwnd(); 2375 HWND right_hwnd = GetRightFakeHwnd();
2356 EXPECT_EQ(gfx::Rect(1920, 0, 200, 300), 2376 EXPECT_EQ(gfx::Rect(1920, 0, 200, 300),
2357 ScreenWin::DIPToScreenRect(right_hwnd, 2377 ScreenWin::DIPToScreenRect(right_hwnd,
2358 gfx::Rect(1920, 0, 100, 150))); 2378 gfx::Rect(1920, 0, 100, 150)));
2359 EXPECT_EQ(gfx::Rect(2000, 496, 100, 200), 2379 EXPECT_EQ(gfx::Rect(2000, 496, 100, 200),
2360 ScreenWin::DIPToScreenRect(right_hwnd, 2380 ScreenWin::DIPToScreenRect(right_hwnd,
2361 gfx::Rect(1960, 248, 50, 100))); 2381 gfx::Rect(1960, 248, 50, 100)));
2382
2383 EXPECT_EQ(gfx::Rect(1900, 200, 100, 100),
2384 ScreenWin::DIPToScreenRect(right_hwnd,
2385 gfx::Rect(1910, 100, 50, 50)));
2362 } 2386 }
2363 2387
2364 TEST_F(ScreenWinTestTwoDisplays1x2x, ClientToDIPRects) { 2388 TEST_F(ScreenWinTestTwoDisplays1x2x, ClientToDIPRects) {
2365 HWND left_hwnd = GetLeftFakeHwnd(); 2389 HWND left_hwnd = GetLeftFakeHwnd();
2366 EXPECT_EQ(gfx::Rect(0, 0, 50, 100), 2390 EXPECT_EQ(gfx::Rect(0, 0, 50, 100),
2367 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); 2391 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100)));
2368 EXPECT_EQ(gfx::Rect(253, 496, 41, 52), 2392 EXPECT_EQ(gfx::Rect(253, 496, 41, 52),
2369 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 2393 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
2370 2394
2371 HWND right_hwnd = GetRightFakeHwnd(); 2395 HWND right_hwnd = GetRightFakeHwnd();
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 EXPECT_EQ(gfx::Rect(168, 330, 28, 36), 2637 EXPECT_EQ(gfx::Rect(168, 330, 28, 36),
2614 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 2638 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
2615 2639
2616 HWND right_hwnd = GetRightFakeHwnd(); 2640 HWND right_hwnd = GetRightFakeHwnd();
2617 EXPECT_EQ(gfx::Rect(534, -80, 200, 300), 2641 EXPECT_EQ(gfx::Rect(534, -80, 200, 300),
2618 ScreenWin::ScreenToDIPRect(right_hwnd, 2642 ScreenWin::ScreenToDIPRect(right_hwnd,
2619 gfx::Rect(800, 120, 200, 300))); 2643 gfx::Rect(800, 120, 200, 300)));
2620 EXPECT_EQ(gfx::Rect(987, 296, 100, 200), 2644 EXPECT_EQ(gfx::Rect(987, 296, 100, 200),
2621 ScreenWin::ScreenToDIPRect(right_hwnd, 2645 ScreenWin::ScreenToDIPRect(right_hwnd,
2622 gfx::Rect(1253, 496, 100, 200))); 2646 gfx::Rect(1253, 496, 100, 200)));
2647
2648 EXPECT_EQ(gfx::Rect(514, 0, 100, 100),
2649 ScreenWin::ScreenToDIPRect(right_hwnd,
2650 gfx::Rect(780, 200, 100, 100)));
2623 } 2651 }
2624 2652
2625 TEST_F(ScreenWinTestTwoDisplays1_5x1x, DIPToScreenRects) { 2653 TEST_F(ScreenWinTestTwoDisplays1_5x1x, DIPToScreenRects) {
2626 HWND left_hwnd = GetLeftFakeHwnd(); 2654 HWND left_hwnd = GetLeftFakeHwnd();
2627 EXPECT_EQ(gfx::Rect(0, 0, 51, 101), 2655 EXPECT_EQ(gfx::Rect(0, 0, 51, 101),
2628 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 34, 67))); 2656 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 34, 67)));
2629 EXPECT_EQ(gfx::Rect(252, 495, 42, 54), 2657 EXPECT_EQ(gfx::Rect(252, 495, 42, 54),
2630 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(168, 330, 28, 36))); 2658 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(168, 330, 28, 36)));
2631 2659
2632 HWND right_hwnd = GetRightFakeHwnd(); 2660 HWND right_hwnd = GetRightFakeHwnd();
2633 EXPECT_EQ(gfx::Rect(800, 120, 200, 300), 2661 EXPECT_EQ(gfx::Rect(800, 120, 200, 300),
2634 ScreenWin::DIPToScreenRect(right_hwnd, 2662 ScreenWin::DIPToScreenRect(right_hwnd,
2635 gfx::Rect(534, -80, 200, 300))); 2663 gfx::Rect(534, -80, 200, 300)));
2636 EXPECT_EQ(gfx::Rect(1253, 496, 100, 200), 2664 EXPECT_EQ(gfx::Rect(1253, 496, 100, 200),
2637 ScreenWin::DIPToScreenRect(right_hwnd, 2665 ScreenWin::DIPToScreenRect(right_hwnd,
2638 gfx::Rect(987, 296, 100, 200))); 2666 gfx::Rect(987, 296, 100, 200)));
2667
2668 EXPECT_EQ(gfx::Rect(780, 200, 100, 100),
2669 ScreenWin::DIPToScreenRect(right_hwnd,
2670 gfx::Rect(514, 0, 100, 100)));
2639 } 2671 }
2640 2672
2641 TEST_F(ScreenWinTestTwoDisplays1_5x1x, ClientToDIPRects) { 2673 TEST_F(ScreenWinTestTwoDisplays1_5x1x, ClientToDIPRects) {
2642 HWND left_hwnd = GetLeftFakeHwnd(); 2674 HWND left_hwnd = GetLeftFakeHwnd();
2643 EXPECT_EQ(gfx::Rect(0, 0, 34, 67), 2675 EXPECT_EQ(gfx::Rect(0, 0, 34, 67),
2644 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); 2676 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100)));
2645 EXPECT_EQ(gfx::Rect(168, 330, 28, 36), 2677 EXPECT_EQ(gfx::Rect(168, 330, 28, 36),
2646 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 2678 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
2647 2679
2648 HWND right_hwnd = GetRightFakeHwnd(); 2680 HWND right_hwnd = GetRightFakeHwnd();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2886 EXPECT_EQ(gfx::Rect(126, 248, 21, 26), 2918 EXPECT_EQ(gfx::Rect(126, 248, 21, 26),
2887 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 2919 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
2888 2920
2889 HWND right_hwnd = GetRightFakeHwnd(); 2921 HWND right_hwnd = GetRightFakeHwnd();
2890 EXPECT_EQ(gfx::Rect(960, 0, 200, 300), 2922 EXPECT_EQ(gfx::Rect(960, 0, 200, 300),
2891 ScreenWin::ScreenToDIPRect(right_hwnd, 2923 ScreenWin::ScreenToDIPRect(right_hwnd,
2892 gfx::Rect(1920, 0, 200, 300))); 2924 gfx::Rect(1920, 0, 200, 300)));
2893 EXPECT_EQ(gfx::Rect(1040, 496, 100, 200), 2925 EXPECT_EQ(gfx::Rect(1040, 496, 100, 200),
2894 ScreenWin::ScreenToDIPRect(right_hwnd, 2926 ScreenWin::ScreenToDIPRect(right_hwnd,
2895 gfx::Rect(2000, 496, 100, 200))); 2927 gfx::Rect(2000, 496, 100, 200)));
2928
2929 EXPECT_EQ(gfx::Rect(940, 200, 100, 100),
2930 ScreenWin::ScreenToDIPRect(right_hwnd,
2931 gfx::Rect(1900, 200, 100, 100)));
2896 } 2932 }
2897 2933
2898 TEST_F(ScreenWinTestTwoDisplays2x1x, DIPToScreenRects) { 2934 TEST_F(ScreenWinTestTwoDisplays2x1x, DIPToScreenRects) {
2899 HWND left_hwnd = GetLeftFakeHwnd(); 2935 HWND left_hwnd = GetLeftFakeHwnd();
2900 EXPECT_EQ(gfx::Rect(0, 0, 50, 100), 2936 EXPECT_EQ(gfx::Rect(0, 0, 50, 100),
2901 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 25, 50))); 2937 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 25, 50)));
2902 EXPECT_EQ(gfx::Rect(252, 496, 42, 52), 2938 EXPECT_EQ(gfx::Rect(252, 496, 42, 52),
2903 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(126, 248, 21, 26))); 2939 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(126, 248, 21, 26)));
2904 2940
2905 HWND right_hwnd = GetRightFakeHwnd(); 2941 HWND right_hwnd = GetRightFakeHwnd();
2906 EXPECT_EQ(gfx::Rect(1920, 0, 200, 300), 2942 EXPECT_EQ(gfx::Rect(1920, 0, 200, 300),
2907 ScreenWin::DIPToScreenRect(right_hwnd, 2943 ScreenWin::DIPToScreenRect(right_hwnd,
2908 gfx::Rect(960, 0, 200, 300))); 2944 gfx::Rect(960, 0, 200, 300)));
2909 EXPECT_EQ(gfx::Rect(2000, 496, 100, 200), 2945 EXPECT_EQ(gfx::Rect(2000, 496, 100, 200),
2910 ScreenWin::DIPToScreenRect(right_hwnd, 2946 ScreenWin::DIPToScreenRect(right_hwnd,
2911 gfx::Rect(1040, 496, 100, 200))); 2947 gfx::Rect(1040, 496, 100, 200)));
2948
2949 EXPECT_EQ(gfx::Rect(1900, 200, 100, 100),
2950 ScreenWin::DIPToScreenRect(right_hwnd,
2951 gfx::Rect(940, 200, 100, 100)));
2912 } 2952 }
2913 2953
2914 TEST_F(ScreenWinTestTwoDisplays2x1x, ClientToDIPRects) { 2954 TEST_F(ScreenWinTestTwoDisplays2x1x, ClientToDIPRects) {
2915 HWND left_hwnd = GetLeftFakeHwnd(); 2955 HWND left_hwnd = GetLeftFakeHwnd();
2916 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), 2956 EXPECT_EQ(gfx::Rect(0, 0, 25, 50),
2917 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); 2957 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100)));
2918 EXPECT_EQ(gfx::Rect(126, 248, 21, 26), 2958 EXPECT_EQ(gfx::Rect(126, 248, 21, 26),
2919 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 2959 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
2920 2960
2921 HWND right_hwnd = GetRightFakeHwnd(); 2961 HWND right_hwnd = GetRightFakeHwnd();
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 EXPECT_EQ(gfx::Rect(126, 248, 21, 26), 3204 EXPECT_EQ(gfx::Rect(126, 248, 21, 26),
3165 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 3205 ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
3166 3206
3167 HWND right_hwnd = GetRightFakeHwnd(); 3207 HWND right_hwnd = GetRightFakeHwnd();
3168 EXPECT_EQ(gfx::Rect(3200, 0, 100, 150), 3208 EXPECT_EQ(gfx::Rect(3200, 0, 100, 150),
3169 ScreenWin::ScreenToDIPRect(right_hwnd, 3209 ScreenWin::ScreenToDIPRect(right_hwnd,
3170 gfx::Rect(6400, 0, 200, 300))); 3210 gfx::Rect(6400, 0, 200, 300)));
3171 EXPECT_EQ(gfx::Rect(3500, 248, 50, 100), 3211 EXPECT_EQ(gfx::Rect(3500, 248, 50, 100),
3172 ScreenWin::ScreenToDIPRect(right_hwnd, 3212 ScreenWin::ScreenToDIPRect(right_hwnd,
3173 gfx::Rect(7000, 496, 100, 200))); 3213 gfx::Rect(7000, 496, 100, 200)));
3214
3215 EXPECT_EQ(gfx::Rect(3190, 100, 50, 50),
3216 ScreenWin::ScreenToDIPRect(right_hwnd,
3217 gfx::Rect(6380, 200, 100, 100)));
3174 } 3218 }
3175 3219
3176 TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, DIPToScreenRects) { 3220 TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, DIPToScreenRects) {
3177 HWND left_hwnd = GetLeftFakeHwnd(); 3221 HWND left_hwnd = GetLeftFakeHwnd();
3178 EXPECT_EQ(gfx::Rect(0, 0, 50, 100), 3222 EXPECT_EQ(gfx::Rect(0, 0, 50, 100),
3179 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 25, 50))); 3223 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 25, 50)));
3180 EXPECT_EQ(gfx::Rect(252, 496, 42, 52), 3224 EXPECT_EQ(gfx::Rect(252, 496, 42, 52),
3181 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(126, 248, 21, 26))); 3225 ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(126, 248, 21, 26)));
3182 3226
3183 HWND right_hwnd = GetRightFakeHwnd(); 3227 HWND right_hwnd = GetRightFakeHwnd();
3184 EXPECT_EQ(gfx::Rect(6400, 0, 200, 300), 3228 EXPECT_EQ(gfx::Rect(6400, 0, 200, 300),
3185 ScreenWin::DIPToScreenRect(right_hwnd, 3229 ScreenWin::DIPToScreenRect(right_hwnd,
3186 gfx::Rect(3200, 0, 100, 150))); 3230 gfx::Rect(3200, 0, 100, 150)));
3187 EXPECT_EQ(gfx::Rect(7000, 496, 100, 200), 3231 EXPECT_EQ(gfx::Rect(7000, 496, 100, 200),
3188 ScreenWin::DIPToScreenRect(right_hwnd, 3232 ScreenWin::DIPToScreenRect(right_hwnd,
3189 gfx::Rect(3500, 248, 50, 100))); 3233 gfx::Rect(3500, 248, 50, 100)));
3234
3235 EXPECT_EQ(gfx::Rect(6380, 200, 100, 100),
3236 ScreenWin::DIPToScreenRect(right_hwnd,
3237 gfx::Rect(3190, 100, 50, 50)));
3190 } 3238 }
3191 3239
3192 TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, ClientToDIPRects) { 3240 TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, ClientToDIPRects) {
3193 HWND left_hwnd = GetLeftFakeHwnd(); 3241 HWND left_hwnd = GetLeftFakeHwnd();
3194 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), 3242 EXPECT_EQ(gfx::Rect(0, 0, 25, 50),
3195 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); 3243 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100)));
3196 EXPECT_EQ(gfx::Rect(126, 248, 21, 26), 3244 EXPECT_EQ(gfx::Rect(126, 248, 21, 26),
3197 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); 3245 ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52)));
3198 3246
3199 HWND right_hwnd = GetRightFakeHwnd(); 3247 HWND right_hwnd = GetRightFakeHwnd();
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
3551 // this test is to make sure we don't crash. 3599 // this test is to make sure we don't crash.
3552 ScreenWin::GetSystemMetricsInDIP(SM_CXSIZEFRAME); 3600 ScreenWin::GetSystemMetricsInDIP(SM_CXSIZEFRAME);
3553 } 3601 }
3554 3602
3555 TEST_F(ScreenWinUninitializedForced2x, GetScaleFactorForHWND) { 3603 TEST_F(ScreenWinUninitializedForced2x, GetScaleFactorForHWND) {
3556 EXPECT_EQ(2.0, ScreenWin::GetScaleFactorForHWND(nullptr)); 3604 EXPECT_EQ(2.0, ScreenWin::GetScaleFactorForHWND(nullptr));
3557 } 3605 }
3558 3606
3559 } // namespace win 3607 } // namespace win
3560 } // namespace display 3608 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/win/screen_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698