| OLD | NEW |
| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 EXPECT_EQ(setup.effective_margins().top, 14); | 222 EXPECT_EQ(setup.effective_margins().top, 14); |
| 223 EXPECT_EQ(setup.effective_margins().right, 6); | 223 EXPECT_EQ(setup.effective_margins().right, 6); |
| 224 EXPECT_EQ(setup.effective_margins().bottom, 16); | 224 EXPECT_EQ(setup.effective_margins().bottom, 16); |
| 225 | 225 |
| 226 // Flip the orientation | 226 // Flip the orientation |
| 227 setup.FlipOrientation(); | 227 setup.FlipOrientation(); |
| 228 | 228 |
| 229 // Expected values. | 229 // Expected values. |
| 230 gfx::Size flipped_page_size(70, 100); | 230 gfx::Size flipped_page_size(70, 100); |
| 231 gfx::Rect flipped_printable_area(9, 0, 50, 92); | 231 gfx::Rect flipped_printable_area(9, 0, 50, 92); |
| 232 gfx::Rect flipped_overlay_area(14, 2, 45, 90); | 232 gfx::Rect flipped_overlay_area(9, 2, 50, 90); |
| 233 gfx::Rect flipped_content_area(14, 7, 45, 80); | 233 gfx::Rect flipped_content_area(9, 14, 50, 73); |
| 234 | 234 |
| 235 // Test values. | 235 // Test values. |
| 236 EXPECT_EQ(flipped_page_size, setup.physical_size()); | 236 EXPECT_EQ(flipped_page_size, setup.physical_size()); |
| 237 EXPECT_EQ(flipped_overlay_area, setup.overlay_area()) << " " << | 237 EXPECT_EQ(flipped_overlay_area, setup.overlay_area()); |
| 238 flipped_page_size.ToString() << " " << flipped_printable_area.ToString(); | 238 EXPECT_EQ(flipped_content_area, setup.content_area()); |
| 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()); | 239 EXPECT_EQ(flipped_printable_area, setup.printable_area()); |
| 242 | 240 |
| 243 // Margin values are updated as per the flipped values. | 241 // Margin values are updated as per the flipped values. |
| 244 EXPECT_EQ(setup.effective_margins().left, 14); | 242 EXPECT_EQ(setup.effective_margins().left, 9); |
| 245 EXPECT_EQ(setup.effective_margins().top, 7); | 243 EXPECT_EQ(setup.effective_margins().top, 14); |
| 246 EXPECT_EQ(setup.effective_margins().right, 11); | 244 EXPECT_EQ(setup.effective_margins().right, 11); |
| 247 EXPECT_EQ(setup.effective_margins().bottom, 13); | 245 EXPECT_EQ(setup.effective_margins().bottom, 13); |
| 248 | 246 |
| 249 // Force requested margins and flip the orientation. | 247 // Force requested margins and flip the orientation. |
| 250 setup.Init(page_size, printable_area, kTextHeight); | 248 setup.Init(page_size, printable_area, kTextHeight); |
| 251 setup.ForceRequestedMargins(margins); | 249 setup.ForceRequestedMargins(margins); |
| 252 EXPECT_EQ(setup.effective_margins().left, 4); | 250 EXPECT_EQ(setup.effective_margins().left, 4); |
| 253 EXPECT_EQ(setup.effective_margins().top, 14); | 251 EXPECT_EQ(setup.effective_margins().top, 14); |
| 254 EXPECT_EQ(setup.effective_margins().right, 6); | 252 EXPECT_EQ(setup.effective_margins().right, 6); |
| 255 EXPECT_EQ(setup.effective_margins().bottom, 7); | 253 EXPECT_EQ(setup.effective_margins().bottom, 7); |
| 256 | 254 |
| 257 // Flip the orientation | 255 // Flip the orientation |
| 258 setup.FlipOrientation(); | 256 setup.FlipOrientation(); |
| 259 | 257 |
| 260 // Expected values. | 258 // Expected values. |
| 261 gfx::Rect new_printable_area(9, 0, 50, 92); | 259 gfx::Rect new_printable_area(9, 0, 50, 92); |
| 262 gfx::Rect new_overlay_area(14, 2, 49, 95); | 260 gfx::Rect new_overlay_area(4, 2, 60, 95); |
| 263 gfx::Rect new_content_area(14, 6, 49, 90); | 261 gfx::Rect new_content_area(4, 14, 60, 79); |
| 264 | 262 |
| 265 // Test values. | 263 // Test values. |
| 266 EXPECT_EQ(flipped_page_size, setup.physical_size()); | 264 EXPECT_EQ(flipped_page_size, setup.physical_size()); |
| 267 EXPECT_EQ(new_overlay_area, setup.overlay_area()); | 265 EXPECT_EQ(new_overlay_area, setup.overlay_area()); |
| 268 EXPECT_EQ(new_content_area, setup.content_area()); | 266 EXPECT_EQ(new_content_area, setup.content_area()); |
| 269 EXPECT_EQ(new_printable_area, setup.printable_area()); | 267 EXPECT_EQ(new_printable_area, setup.printable_area()); |
| 270 | 268 |
| 271 // Margins values are changed respectively. | 269 // Margins values are changed respectively. |
| 272 EXPECT_EQ(setup.effective_margins().left,14); | 270 EXPECT_EQ(setup.effective_margins().left, 4); |
| 273 EXPECT_EQ(setup.effective_margins().top, 6); | 271 EXPECT_EQ(setup.effective_margins().top, 14); |
| 274 EXPECT_EQ(setup.effective_margins().right, 7); | 272 EXPECT_EQ(setup.effective_margins().right, 6); |
| 275 EXPECT_EQ(setup.effective_margins().bottom, 4); | 273 EXPECT_EQ(setup.effective_margins().bottom, 7); |
| 276 } | 274 } |
| OLD | NEW |