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(
16 1, NULL
, gfx::Size(1200, 1200), gfx::Rect(0, 0, 400, 1100));
17 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
18 EXPECT_EQ(0, page_content
.x());
19 EXPECT_EQ(0, page_content
.y());
20 EXPECT_EQ(400, page_content
.width());
21 EXPECT_EQ(1100, page_content
.height());
24 page
= new PrintedPage(
25 1, NULL
, gfx::Size(500, 1200), gfx::Rect(0, 0, 400, 1100));
26 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
27 EXPECT_EQ(250, page_content
.x());
28 EXPECT_EQ(0, page_content
.y());
29 EXPECT_EQ(400, page_content
.width());
30 EXPECT_EQ(1100, page_content
.height());
33 page
= new PrintedPage(
34 1, NULL
, gfx::Size(1200, 500), gfx::Rect(0, 0, 400, 1100));
35 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
36 EXPECT_EQ(0, page_content
.x());
37 EXPECT_EQ(250, page_content
.y());
38 EXPECT_EQ(400, page_content
.width());
39 EXPECT_EQ(1100, page_content
.height());
41 // Both X and Y centered.
43 new PrintedPage(1, NULL
, gfx::Size(500, 500), gfx::Rect(0, 0, 400, 1100));
44 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
45 EXPECT_EQ(250, page_content
.x());
46 EXPECT_EQ(250, page_content
.y());
47 EXPECT_EQ(400, page_content
.width());
48 EXPECT_EQ(1100, page_content
.height());
52 TEST(PrintedPageTest
, Shrink
) {
53 scoped_refptr
<PrintedPage
> page
= new PrintedPage(
54 1, NULL
, gfx::Size(1200, 1200), gfx::Rect(0, 0, 400, 1100));
55 EXPECT_EQ(0.0f
, page
->shrink_factor());
56 page
->set_shrink_factor(0.2f
);
57 EXPECT_EQ(0.2f
, page
->shrink_factor());
58 page
->set_shrink_factor(0.7f
);
59 EXPECT_EQ(0.7f
, page
->shrink_factor());
63 } // namespace printing