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
3 // found in the LICENSE file.
5 #include "printing/printed_page.h"
6 #include "testing/gtest/include/gtest/gtest.h"
10 TEST(PrintedPageTest
, GetCenteredPageContentRect
) {
11 scoped_refptr
<PrintedPage
> page
;
12 gfx::Rect page_content
;
15 page
= new PrintedPage(1,
17 gfx::Size(1200, 1200),
18 gfx::Rect(0, 0, 400, 1100),
20 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
21 EXPECT_EQ(0, page_content
.x());
22 EXPECT_EQ(0, page_content
.y());
23 EXPECT_EQ(400, page_content
.width());
24 EXPECT_EQ(1100, page_content
.height());
25 EXPECT_EQ(0.2f
, page
->shrink_factor());
28 page
= new PrintedPage(1,
31 gfx::Rect(0, 0, 400, 1100),
33 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
34 EXPECT_EQ(250, page_content
.x());
35 EXPECT_EQ(0, page_content
.y());
36 EXPECT_EQ(400, page_content
.width());
37 EXPECT_EQ(1100, page_content
.height());
38 EXPECT_EQ(0.8f
, page
->shrink_factor());
41 page
= new PrintedPage(1,
44 gfx::Rect(0, 0, 400, 1100),
46 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
47 EXPECT_EQ(0, page_content
.x());
48 EXPECT_EQ(250, page_content
.y());
49 EXPECT_EQ(400, page_content
.width());
50 EXPECT_EQ(1100, page_content
.height());
51 EXPECT_EQ(1.0f
, page
->shrink_factor());
53 // Both X and Y centered.
54 page
= new PrintedPage(1,
57 gfx::Rect(0, 0, 400, 1100),
59 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
60 EXPECT_EQ(250, page_content
.x());
61 EXPECT_EQ(250, page_content
.y());
62 EXPECT_EQ(400, page_content
.width());
63 EXPECT_EQ(1100, page_content
.height());
64 EXPECT_EQ(0.3f
, page
->shrink_factor());
67 } // namespace printing