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

Unified Diff: remoting/client/desktop_viewport_unittest.cc

Issue 2857113002: [Remoting Client] Fix scaling bug in ViewMatrix (Closed)
Patch Set: Resolve Feedback Created 3 years, 8 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 | « no previous file | remoting/client/view_matrix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/desktop_viewport_unittest.cc
diff --git a/remoting/client/desktop_viewport_unittest.cc b/remoting/client/desktop_viewport_unittest.cc
index 8e12230233e591171c310d9e0941e4b2ba06966e..2c1999849ef96ede56e6b4e46ff9e036c6a20065 100644
--- a/remoting/client/desktop_viewport_unittest.cc
+++ b/remoting/client/desktop_viewport_unittest.cc
@@ -28,6 +28,8 @@ class DesktopViewportTest : public testing::Test {
float offset_x,
float offset_y);
+ ViewMatrix ReleaseReceivedTransformation();
+
DesktopViewport viewport_;
private:
@@ -74,6 +76,13 @@ void DesktopViewportTest::AssertTransformationReceived(
received_transformation_ = ViewMatrix();
}
+ViewMatrix DesktopViewportTest::ReleaseReceivedTransformation() {
+ EXPECT_FALSE(received_transformation_.IsEmpty());
+ ViewMatrix out = received_transformation_;
+ received_transformation_ = ViewMatrix();
+ return out;
+}
+
void DesktopViewportTest::OnTransformationChanged(const ViewMatrix& matrix) {
ASSERT_TRUE(received_transformation_.IsEmpty())
<< "Previous matrix has not been asserted.";
@@ -251,4 +260,36 @@ TEST_F(DesktopViewportTest, TestSetViewportCenter) {
AssertTransformationReceived(FROM_HERE, 1.25f, -8.f, -4.5f);
}
+TEST_F(DesktopViewportTest, TestScaleDesktop) {
+ // Number in surface coordinate.
+ //
+ // +====+------+
+ // | VP | DP |
+ // | | | 3
+ // +====+------+
+ // 4
+ viewport_.SetDesktopSize(8, 6);
+ viewport_.SetSurfaceSize(2, 3);
+ AssertTransformationReceived(FROM_HERE, 0.5f, 0.f, 0.f);
+
+ ViewMatrix old_transformation(0.5f, {0.f, 0.f});
+
+ ViewMatrix::Point surface_point = old_transformation.MapPoint({1.2f, 1.3f});
+
+ // Scale a little bit at a pivot point.
+ viewport_.ScaleDesktop(surface_point.x, surface_point.y, 1.1f);
+
+ ViewMatrix new_transformation = ReleaseReceivedTransformation();
+
+ // Verify the pivot point is fixed.
+ ViewMatrix::Point new_surface_point =
+ new_transformation.MapPoint({1.2f, 1.3f});
+ ASSERT_FLOAT_EQ(surface_point.x, new_surface_point.x);
+ ASSERT_FLOAT_EQ(surface_point.y, new_surface_point.y);
+
+ // Verify the scale is correct.
+ ASSERT_FLOAT_EQ(old_transformation.GetScale() * 1.1f,
+ new_transformation.GetScale());
+}
+
} // namespace remoting
« no previous file with comments | « no previous file | remoting/client/view_matrix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698