| 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/printed_page.h" | 5 #include "printing/printed_page.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 namespace printing { | 8 namespace printing { |
| 9 | 9 |
| 10 TEST(PrintedPageTest, GetCenteredPageContentRect) { | 10 TEST(PrintedPageTest, GetCenteredPageContentRect) { |
| 11 scoped_refptr<PrintedPage> page; | 11 scoped_refptr<PrintedPage> page; |
| 12 gfx::Rect page_content; | 12 gfx::Rect page_content; |
| 13 | 13 |
| 14 // No centering. | 14 // No centering. |
| 15 page = new PrintedPage( | 15 page = new PrintedPage(1, |
| 16 1, NULL, gfx::Size(1200, 1200), gfx::Rect(0, 0, 400, 1100)); | 16 scoped_ptr<MetafilePlayer>(), |
| 17 gfx::Size(1200, 1200), |
| 18 gfx::Rect(0, 0, 400, 1100)); |
| 17 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); | 19 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); |
| 18 EXPECT_EQ(0, page_content.x()); | 20 EXPECT_EQ(0, page_content.x()); |
| 19 EXPECT_EQ(0, page_content.y()); | 21 EXPECT_EQ(0, page_content.y()); |
| 20 EXPECT_EQ(400, page_content.width()); | 22 EXPECT_EQ(400, page_content.width()); |
| 21 EXPECT_EQ(1100, page_content.height()); | 23 EXPECT_EQ(1100, page_content.height()); |
| 22 | 24 |
| 23 // X centered. | 25 // X centered. |
| 24 page = new PrintedPage( | 26 page = new PrintedPage(1, |
| 25 1, NULL, gfx::Size(500, 1200), gfx::Rect(0, 0, 400, 1100)); | 27 scoped_ptr<MetafilePlayer>(), |
| 28 gfx::Size(500, 1200), |
| 29 gfx::Rect(0, 0, 400, 1100)); |
| 26 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); | 30 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); |
| 27 EXPECT_EQ(250, page_content.x()); | 31 EXPECT_EQ(250, page_content.x()); |
| 28 EXPECT_EQ(0, page_content.y()); | 32 EXPECT_EQ(0, page_content.y()); |
| 29 EXPECT_EQ(400, page_content.width()); | 33 EXPECT_EQ(400, page_content.width()); |
| 30 EXPECT_EQ(1100, page_content.height()); | 34 EXPECT_EQ(1100, page_content.height()); |
| 31 | 35 |
| 32 // Y centered. | 36 // Y centered. |
| 33 page = new PrintedPage( | 37 page = new PrintedPage(1, |
| 34 1, NULL, gfx::Size(1200, 500), gfx::Rect(0, 0, 400, 1100)); | 38 scoped_ptr<MetafilePlayer>(), |
| 39 gfx::Size(1200, 500), |
| 40 gfx::Rect(0, 0, 400, 1100)); |
| 35 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); | 41 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); |
| 36 EXPECT_EQ(0, page_content.x()); | 42 EXPECT_EQ(0, page_content.x()); |
| 37 EXPECT_EQ(250, page_content.y()); | 43 EXPECT_EQ(250, page_content.y()); |
| 38 EXPECT_EQ(400, page_content.width()); | 44 EXPECT_EQ(400, page_content.width()); |
| 39 EXPECT_EQ(1100, page_content.height()); | 45 EXPECT_EQ(1100, page_content.height()); |
| 40 | 46 |
| 41 // Both X and Y centered. | 47 // Both X and Y centered. |
| 42 page = | 48 page = new PrintedPage(1, |
| 43 new PrintedPage(1, NULL, gfx::Size(500, 500), gfx::Rect(0, 0, 400, 1100)); | 49 scoped_ptr<MetafilePlayer>(), |
| 50 gfx::Size(500, 500), |
| 51 gfx::Rect(0, 0, 400, 1100)); |
| 44 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); | 52 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); |
| 45 EXPECT_EQ(250, page_content.x()); | 53 EXPECT_EQ(250, page_content.x()); |
| 46 EXPECT_EQ(250, page_content.y()); | 54 EXPECT_EQ(250, page_content.y()); |
| 47 EXPECT_EQ(400, page_content.width()); | 55 EXPECT_EQ(400, page_content.width()); |
| 48 EXPECT_EQ(1100, page_content.height()); | 56 EXPECT_EQ(1100, page_content.height()); |
| 49 } | 57 } |
| 50 | 58 |
| 51 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
| 52 TEST(PrintedPageTest, Shrink) { | 60 TEST(PrintedPageTest, Shrink) { |
| 53 scoped_refptr<PrintedPage> page = new PrintedPage( | 61 scoped_refptr<PrintedPage> page = |
| 54 1, NULL, gfx::Size(1200, 1200), gfx::Rect(0, 0, 400, 1100)); | 62 new PrintedPage(1, |
| 63 scoped_ptr<MetafilePlayer>(), |
| 64 gfx::Size(1200, 1200), |
| 65 gfx::Rect(0, 0, 400, 1100)); |
| 55 EXPECT_EQ(0.0f, page->shrink_factor()); | 66 EXPECT_EQ(0.0f, page->shrink_factor()); |
| 56 page->set_shrink_factor(0.2f); | 67 page->set_shrink_factor(0.2f); |
| 57 EXPECT_EQ(0.2f, page->shrink_factor()); | 68 EXPECT_EQ(0.2f, page->shrink_factor()); |
| 58 page->set_shrink_factor(0.7f); | 69 page->set_shrink_factor(0.7f); |
| 59 EXPECT_EQ(0.7f, page->shrink_factor()); | 70 EXPECT_EQ(0.7f, page->shrink_factor()); |
| 60 } | 71 } |
| 61 #endif // OS_WIN | 72 #endif // OS_WIN |
| 62 | 73 |
| 63 } // namespace printing | 74 } // namespace printing |
| OLD | NEW |