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

Unified Diff: printing/page_setup_unittest.cc

Issue 8342059: Clarify that the custom margin value is not validated and add tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | printing/print_settings.h » ('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 8d65e72bebae2da86d8cf07bad20898433f404e6..54e436c27d28a3e7e04f1c1878fcc823be7a2fe1 100644
--- a/printing/page_setup_unittest.cc
+++ b/printing/page_setup_unittest.cc
@@ -161,3 +161,32 @@ TEST(PageSetupTest, HardCoded) {
" " << page_size.ToString() << " " << printable_area.ToString() <<
" " << kTextHeight;
}
+
+TEST(PageSetupTest, OutOfRangeMargins) {
+ printing::PageMargins margins;
+ margins.header = 0;
+ margins.footer = 0;
+ margins.left = -10;
+ margins.top = -11;
+ margins.right = -12;
+ margins.bottom = -13;
+
+ gfx::Size page_size(100, 100);
+ gfx::Rect printable_area(1, 2, 96, 94);
+
+ // Make the calculations.
+ printing::PageSetup setup;
+ setup.SetRequestedMargins(margins);
+ setup.Init(page_size, printable_area, 0);
+
+ EXPECT_EQ(setup.effective_margins().left, 1);
+ EXPECT_EQ(setup.effective_margins().top, 2);
+ EXPECT_EQ(setup.effective_margins().right, 3);
+ EXPECT_EQ(setup.effective_margins().bottom, 4);
+
+ setup.ForceRequestedMargins(margins);
+ EXPECT_EQ(setup.effective_margins().left, 0);
+ EXPECT_EQ(setup.effective_margins().top, 0);
+ EXPECT_EQ(setup.effective_margins().right, 0);
+ EXPECT_EQ(setup.effective_margins().bottom, 0);
+}
« no previous file with comments | « no previous file | printing/print_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698