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

Unified Diff: ui/gfx/display_unittest.cc

Issue 10540091: Rename gfx::Monitor to gfx::Display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | « ui/gfx/display.cc ('k') | ui/gfx/monitor.h » ('j') | ui/gfx/screen.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/display_unittest.cc
diff --git a/ui/gfx/display_unittest.cc b/ui/gfx/display_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..39a5fb679d67436ef0aedfa77bc2b16fe35790ab
--- /dev/null
+++ b/ui/gfx/display_unittest.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/display.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/insets.h"
+
+namespace {
+
+TEST(DisplayTest, WorkArea) {
+ gfx::Display display(0, gfx::Rect(0, 0, 100, 100));
+ EXPECT_EQ("0,0 100x100", display.bounds().ToString());
+ EXPECT_EQ("0,0 100x100", display.work_area().ToString());
+
+ display.set_work_area(gfx::Rect(3, 4, 90, 80));
+ EXPECT_EQ("0,0 100x100", display.bounds().ToString());
+ EXPECT_EQ("3,4 90x80", display.work_area().ToString());
+
+ display.SetScaleAndBounds(1.0f, gfx::Rect(10, 20, 50, 50));
+ EXPECT_EQ("0,0 50x50", display.bounds().ToString());
+ EXPECT_EQ("3,4 40x30", display.work_area().ToString());
+
+ display.SetSize(gfx::Size(200, 200));
+ EXPECT_EQ("3,4 190x180", display.work_area().ToString());
+
+ display.UpdateWorkAreaFromInsets(gfx::Insets(3, 4, 5, 6));
+ EXPECT_EQ("4,3 190x192", display.work_area().ToString());
+}
+
+TEST(DisplayTest, Scale) {
+ gfx::Display display(0, gfx::Rect(0, 0, 100, 100));
+ display.set_work_area(gfx::Rect(10, 10, 80, 80));
+ EXPECT_EQ("0,0 100x100", display.bounds().ToString());
+ EXPECT_EQ("10,10 80x80", display.work_area().ToString());
+
+ // Scale it back to 2x
+ display.SetScaleAndBounds(2.0f, gfx::Rect(0, 0, 140, 140));
+ EXPECT_EQ("0,0 70x70", display.bounds().ToString());
+ EXPECT_EQ("10,10 50x50", display.work_area().ToString());
+
+ // Scale it back to 1x
+ display.SetScaleAndBounds(1.0f, gfx::Rect(0, 0, 100, 100));
+ EXPECT_EQ("0,0 100x100", display.bounds().ToString());
+ EXPECT_EQ("10,10 80x80", display.work_area().ToString());
+}
+
+}
« no previous file with comments | « ui/gfx/display.cc ('k') | ui/gfx/monitor.h » ('j') | ui/gfx/screen.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698