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

Unified Diff: printing/printed_page_unittest.cc

Issue 2878022: Add PrintedPage::GetCenteredPageContentRect so Mac and Win can share code. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: remove #include for gtest Created 10 years, 5 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 | « printing/printed_page.cc ('k') | printing/printing.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/printed_page_unittest.cc
diff --git a/printing/printed_page_unittest.cc b/printing/printed_page_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..91b2111a92ccf44e383f4578093e31eef51c158e
--- /dev/null
+++ b/printing/printed_page_unittest.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2010 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 "printing/printed_page.h"
+
+#include <string>
+#include <vector>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace printing {
+
+TEST(PrintedPageTest, GetCenteredPageContentRect) {
+ scoped_refptr<PrintedPage> page;
+ gfx::Rect page_content;
+
+ // No centering.
+ page =new PrintedPage(1,
+ NULL,
+ gfx::Size(1200, 1200),
+ gfx::Rect(0, 0, 400, 1100),
+ true);
+ page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
+ EXPECT_EQ(0, page_content.x());
+ EXPECT_EQ(0, page_content.y());
+ EXPECT_EQ(400, page_content.width());
+ EXPECT_EQ(1100, page_content.height());
+
+ // X centered.
+ page = new PrintedPage(1,
+ NULL,
+ gfx::Size(500, 1200),
+ gfx::Rect(0, 0, 400, 1100),
+ true);
+ page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
+ EXPECT_EQ(250, page_content.x());
+ EXPECT_EQ(0, page_content.y());
+ EXPECT_EQ(400, page_content.width());
+ EXPECT_EQ(1100, page_content.height());
+
+ // Y centered.
+ page = new PrintedPage(1,
+ NULL,
+ gfx::Size(1200, 500),
+ gfx::Rect(0, 0, 400, 1100),
+ true);
+ page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
+ EXPECT_EQ(0, page_content.x());
+ EXPECT_EQ(250, page_content.y());
+ EXPECT_EQ(400, page_content.width());
+ EXPECT_EQ(1100, page_content.height());
+
+ // Both X and Y centered.
+ page = new PrintedPage(1,
+ NULL,
+ gfx::Size(500, 500),
+ gfx::Rect(0, 0, 400, 1100),
+ true);
+ page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
+ EXPECT_EQ(250, page_content.x());
+ EXPECT_EQ(250, page_content.y());
+ EXPECT_EQ(400, page_content.width());
+ EXPECT_EQ(1100, page_content.height());
+}
+
+} // namespace printing
« no previous file with comments | « printing/printed_page.cc ('k') | printing/printing.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698