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

Side by Side Diff: webkit/plugins/ppapi/ppb_graphics_2d_impl_unittest.cc

Issue 11028127: Implicit coversion operators from integer geometry types to floating point. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 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
OLDNEW
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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/gfx/point.h" 7 #include "ui/gfx/point.h"
8 #include "ui/gfx/rect.h" 8 #include "ui/gfx/rect.h"
9 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" 9 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 { 10, 10, 20, 20, 5, 5, 10, 10, -6, -4, -3, -2, 0.5, true }, 59 { 10, 10, 20, 20, 5, 5, 10, 10, -6, -4, -3, -2, 0.5, true },
60 { 10, 10, 20, 20, 5, 5, 10, 10, -6, -3, -3, -1, 0.5, false }, 60 { 10, 10, 20, 20, 5, 5, 10, 10, -6, -3, -3, -1, 0.5, false },
61 }; 61 };
62 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 62 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
63 gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); 63 gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
64 gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); 64 gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
65 gfx::Rect orig = r1; 65 gfx::Rect orig = r1;
66 gfx::Point delta(tests[i].dx1, tests[i].dy1); 66 gfx::Point delta(tests[i].dx1, tests[i].dy1);
67 bool res = webkit::ppapi::PPB_Graphics2D_Impl::ConvertToLogicalPixels( 67 bool res = webkit::ppapi::PPB_Graphics2D_Impl::ConvertToLogicalPixels(
68 tests[i].scale, &r1, &delta); 68 tests[i].scale, &r1, &delta);
69 EXPECT_TRUE(r1.Equals(r2)); 69 EXPECT_EQ(r2.ToString(), r1.ToString());
70 EXPECT_EQ(res, tests[i].result); 70 EXPECT_EQ(res, tests[i].result);
71 if (res) { 71 if (res) {
72 EXPECT_EQ(delta, gfx::Point(tests[i].dx2, tests[i].dy2)); 72 EXPECT_EQ(delta, gfx::Point(tests[i].dx2, tests[i].dy2));
73 } 73 }
74 // Reverse the scale and ensure all the original pixels are still inside 74 // Reverse the scale and ensure all the original pixels are still inside
75 // the result. 75 // the result.
76 webkit::ppapi::PPB_Graphics2D_Impl::ConvertToLogicalPixels( 76 webkit::ppapi::PPB_Graphics2D_Impl::ConvertToLogicalPixels(
77 1.0f / tests[i].scale, &r1, NULL); 77 1.0f / tests[i].scale, &r1, NULL);
78 EXPECT_TRUE(r1.Contains(orig)); 78 EXPECT_TRUE(r1.Contains(orig));
79 } 79 }
80 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698