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

Unified Diff: printing/page_setup_unittest.cc

Issue 8351063: PrintPreview: [LINUX] Update the margin values after flipping the paper orientation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 1 month 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/page_setup.cc ('k') | printing/print_settings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/page_setup_unittest.cc
diff --git a/printing/page_setup_unittest.cc b/printing/page_setup_unittest.cc
index 54e436c27d28a3e7e04f1c1878fcc823be7a2fe1..00c8f2a0c9f6b0f19a4c37260510631b24a3328b 100644
--- a/printing/page_setup_unittest.cc
+++ b/printing/page_setup_unittest.cc
@@ -190,3 +190,87 @@ TEST(PageSetupTest, OutOfRangeMargins) {
EXPECT_EQ(setup.effective_margins().right, 0);
EXPECT_EQ(setup.effective_margins().bottom, 0);
}
+
+TEST(PageSetupTest, FlipOrientation) {
+ // Margins.
+ printing::PageMargins margins;
+ margins.header = 2;
+ margins.footer = 3;
+ margins.left = 4;
+ margins.top = 14;
+ margins.right = 6;
+ margins.bottom = 7;
+ int kTextHeight = 5;
+
+ // Page description.
+ gfx::Size page_size(100, 70);
+ gfx::Rect printable_area(8, 9, 92, 50);
+
+ // Make the calculations.
+ printing::PageSetup setup;
+ setup.SetRequestedMargins(margins);
+ setup.Init(page_size, printable_area, kTextHeight);
+
+ gfx::Rect overlay_area(8, 9, 86, 50);
+ gfx::Rect content_area(8, 14, 86, 40);
+
+ EXPECT_EQ(page_size, setup.physical_size());
+ EXPECT_EQ(overlay_area, setup.overlay_area());
+ EXPECT_EQ(content_area, setup.content_area());
+
+ EXPECT_EQ(setup.effective_margins().left, 8);
+ EXPECT_EQ(setup.effective_margins().top, 14);
+ EXPECT_EQ(setup.effective_margins().right, 6);
+ EXPECT_EQ(setup.effective_margins().bottom, 16);
+
+ // Flip the orientation
+ setup.FlipOrientation();
+
+ // Expected values.
+ gfx::Size flipped_page_size(70, 100);
+ gfx::Rect flipped_printable_area(9, 0, 50, 92);
+ gfx::Rect flipped_overlay_area(14, 2, 45, 90);
+ gfx::Rect flipped_content_area(14, 7, 45, 80);
+
+ // Test values.
+ EXPECT_EQ(flipped_page_size, setup.physical_size());
+ EXPECT_EQ(flipped_overlay_area, setup.overlay_area()) << " " <<
+ flipped_page_size.ToString() << " " << flipped_printable_area.ToString();
+ EXPECT_EQ(flipped_content_area, setup.content_area()) << " " <<
+ flipped_page_size.ToString() << " " << flipped_printable_area.ToString();
+ EXPECT_EQ(flipped_printable_area, setup.printable_area());
+
+ // Margin values are updated as per the flipped values.
+ EXPECT_EQ(setup.effective_margins().left, 14);
+ EXPECT_EQ(setup.effective_margins().top, 7);
+ EXPECT_EQ(setup.effective_margins().right, 11);
+ EXPECT_EQ(setup.effective_margins().bottom, 13);
+
+ // Force requested margins and flip the orientation.
+ setup.Init(page_size, printable_area, kTextHeight);
+ setup.ForceRequestedMargins(margins);
+ EXPECT_EQ(setup.effective_margins().left, 4);
+ EXPECT_EQ(setup.effective_margins().top, 14);
+ EXPECT_EQ(setup.effective_margins().right, 6);
+ EXPECT_EQ(setup.effective_margins().bottom, 7);
+
+ // Flip the orientation
+ setup.FlipOrientation();
+
+ // Expected values.
+ gfx::Rect new_printable_area(9, 0, 50, 92);
+ gfx::Rect new_overlay_area(14, 2, 49, 95);
+ gfx::Rect new_content_area(14, 6, 49, 90);
+
+ // Test values.
+ EXPECT_EQ(flipped_page_size, setup.physical_size());
+ EXPECT_EQ(new_overlay_area, setup.overlay_area());
+ EXPECT_EQ(new_content_area, setup.content_area());
+ EXPECT_EQ(new_printable_area, setup.printable_area());
+
+ // Margins values are changed respectively.
+ EXPECT_EQ(setup.effective_margins().left,14);
+ EXPECT_EQ(setup.effective_margins().top, 6);
+ EXPECT_EQ(setup.effective_margins().right, 7);
+ EXPECT_EQ(setup.effective_margins().bottom, 4);
+}
« no previous file with comments | « printing/page_setup.cc ('k') | printing/print_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698