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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | printing/print_settings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/page_setup.h" 5 #include "printing/page_setup.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <time.h> 8 #include <time.h>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 EXPECT_EQ(effective_margins.top, setup.effective_margins().top) << 154 EXPECT_EQ(effective_margins.top, setup.effective_margins().top) <<
155 " " << page_size.ToString() << " " << printable_area.ToString() << 155 " " << page_size.ToString() << " " << printable_area.ToString() <<
156 " " << kTextHeight; 156 " " << kTextHeight;
157 EXPECT_EQ(effective_margins.right, setup.effective_margins().right) << 157 EXPECT_EQ(effective_margins.right, setup.effective_margins().right) <<
158 " " << page_size.ToString() << " " << printable_area.ToString() << 158 " " << page_size.ToString() << " " << printable_area.ToString() <<
159 " " << kTextHeight; 159 " " << kTextHeight;
160 EXPECT_EQ(effective_margins.bottom, setup.effective_margins().bottom) << 160 EXPECT_EQ(effective_margins.bottom, setup.effective_margins().bottom) <<
161 " " << page_size.ToString() << " " << printable_area.ToString() << 161 " " << page_size.ToString() << " " << printable_area.ToString() <<
162 " " << kTextHeight; 162 " " << kTextHeight;
163 } 163 }
164
165 TEST(PageSetupTest, OutOfRangeMargins) {
166 printing::PageMargins margins;
167 margins.header = 0;
168 margins.footer = 0;
169 margins.left = -10;
170 margins.top = -11;
171 margins.right = -12;
172 margins.bottom = -13;
173
174 gfx::Size page_size(100, 100);
175 gfx::Rect printable_area(1, 2, 96, 94);
176
177 // Make the calculations.
178 printing::PageSetup setup;
179 setup.SetRequestedMargins(margins);
180 setup.Init(page_size, printable_area, 0);
181
182 EXPECT_EQ(setup.effective_margins().left, 1);
183 EXPECT_EQ(setup.effective_margins().top, 2);
184 EXPECT_EQ(setup.effective_margins().right, 3);
185 EXPECT_EQ(setup.effective_margins().bottom, 4);
186
187 setup.ForceRequestedMargins(margins);
188 EXPECT_EQ(setup.effective_margins().left, 0);
189 EXPECT_EQ(setup.effective_margins().top, 0);
190 EXPECT_EQ(setup.effective_margins().right, 0);
191 EXPECT_EQ(setup.effective_margins().bottom, 0);
192 }
OLDNEW
« 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