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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/page_setup.cc ('k') | printing/print_settings.cc » ('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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 EXPECT_EQ(setup.effective_margins().top, 2); 183 EXPECT_EQ(setup.effective_margins().top, 2);
184 EXPECT_EQ(setup.effective_margins().right, 3); 184 EXPECT_EQ(setup.effective_margins().right, 3);
185 EXPECT_EQ(setup.effective_margins().bottom, 4); 185 EXPECT_EQ(setup.effective_margins().bottom, 4);
186 186
187 setup.ForceRequestedMargins(margins); 187 setup.ForceRequestedMargins(margins);
188 EXPECT_EQ(setup.effective_margins().left, 0); 188 EXPECT_EQ(setup.effective_margins().left, 0);
189 EXPECT_EQ(setup.effective_margins().top, 0); 189 EXPECT_EQ(setup.effective_margins().top, 0);
190 EXPECT_EQ(setup.effective_margins().right, 0); 190 EXPECT_EQ(setup.effective_margins().right, 0);
191 EXPECT_EQ(setup.effective_margins().bottom, 0); 191 EXPECT_EQ(setup.effective_margins().bottom, 0);
192 } 192 }
193
194 TEST(PageSetupTest, FlipOrientation) {
195 // Margins.
196 printing::PageMargins margins;
197 margins.header = 2;
198 margins.footer = 3;
199 margins.left = 4;
200 margins.top = 14;
201 margins.right = 6;
202 margins.bottom = 7;
203 int kTextHeight = 5;
204
205 // Page description.
206 gfx::Size page_size(100, 70);
207 gfx::Rect printable_area(8, 9, 92, 50);
208
209 // Make the calculations.
210 printing::PageSetup setup;
211 setup.SetRequestedMargins(margins);
212 setup.Init(page_size, printable_area, kTextHeight);
213
214 gfx::Rect overlay_area(8, 9, 86, 50);
215 gfx::Rect content_area(8, 14, 86, 40);
216
217 EXPECT_EQ(page_size, setup.physical_size());
218 EXPECT_EQ(overlay_area, setup.overlay_area());
219 EXPECT_EQ(content_area, setup.content_area());
220
221 EXPECT_EQ(setup.effective_margins().left, 8);
222 EXPECT_EQ(setup.effective_margins().top, 14);
223 EXPECT_EQ(setup.effective_margins().right, 6);
224 EXPECT_EQ(setup.effective_margins().bottom, 16);
225
226 // Flip the orientation
227 setup.FlipOrientation();
228
229 // Expected values.
230 gfx::Size flipped_page_size(70, 100);
231 gfx::Rect flipped_printable_area(9, 0, 50, 92);
232 gfx::Rect flipped_overlay_area(14, 2, 45, 90);
233 gfx::Rect flipped_content_area(14, 7, 45, 80);
234
235 // Test values.
236 EXPECT_EQ(flipped_page_size, setup.physical_size());
237 EXPECT_EQ(flipped_overlay_area, setup.overlay_area()) << " " <<
238 flipped_page_size.ToString() << " " << flipped_printable_area.ToString();
239 EXPECT_EQ(flipped_content_area, setup.content_area()) << " " <<
240 flipped_page_size.ToString() << " " << flipped_printable_area.ToString();
241 EXPECT_EQ(flipped_printable_area, setup.printable_area());
242
243 // Margin values are updated as per the flipped values.
244 EXPECT_EQ(setup.effective_margins().left, 14);
245 EXPECT_EQ(setup.effective_margins().top, 7);
246 EXPECT_EQ(setup.effective_margins().right, 11);
247 EXPECT_EQ(setup.effective_margins().bottom, 13);
248
249 // Force requested margins and flip the orientation.
250 setup.Init(page_size, printable_area, kTextHeight);
251 setup.ForceRequestedMargins(margins);
252 EXPECT_EQ(setup.effective_margins().left, 4);
253 EXPECT_EQ(setup.effective_margins().top, 14);
254 EXPECT_EQ(setup.effective_margins().right, 6);
255 EXPECT_EQ(setup.effective_margins().bottom, 7);
256
257 // Flip the orientation
258 setup.FlipOrientation();
259
260 // Expected values.
261 gfx::Rect new_printable_area(9, 0, 50, 92);
262 gfx::Rect new_overlay_area(14, 2, 49, 95);
263 gfx::Rect new_content_area(14, 6, 49, 90);
264
265 // Test values.
266 EXPECT_EQ(flipped_page_size, setup.physical_size());
267 EXPECT_EQ(new_overlay_area, setup.overlay_area());
268 EXPECT_EQ(new_content_area, setup.content_area());
269 EXPECT_EQ(new_printable_area, setup.printable_area());
270
271 // Margins values are changed respectively.
272 EXPECT_EQ(setup.effective_margins().left,14);
273 EXPECT_EQ(setup.effective_margins().top, 6);
274 EXPECT_EQ(setup.effective_margins().right, 7);
275 EXPECT_EQ(setup.effective_margins().bottom, 4);
276 }
OLDNEW
« 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