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,
16 scoped_ptr
<MetafilePlayer
>(),
17 gfx::Size(1200, 1200),
18 gfx::Rect(0, 0, 400, 1100));
19 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
20 EXPECT_EQ(0, page_content
.x());
21 EXPECT_EQ(0, page_content
.y());
22 EXPECT_EQ(400, page_content
.width());
23 EXPECT_EQ(1100, page_content
.height());
26 page
= new PrintedPage(1,
27 scoped_ptr
<MetafilePlayer
>(),
29 gfx::Rect(0, 0, 400, 1100));
30 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
31 EXPECT_EQ(250, page_content
.x());
32 EXPECT_EQ(0, page_content
.y());
33 EXPECT_EQ(400, page_content
.width());
34 EXPECT_EQ(1100, page_content
.height());
37 page
= new PrintedPage(1,
38 scoped_ptr
<MetafilePlayer
>(),
40 gfx::Rect(0, 0, 400, 1100));
41 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
42 EXPECT_EQ(0, page_content
.x());
43 EXPECT_EQ(250, page_content
.y());
44 EXPECT_EQ(400, page_content
.width());
45 EXPECT_EQ(1100, page_content
.height());
47 // Both X and Y centered.
48 page
= new PrintedPage(1,
49 scoped_ptr
<MetafilePlayer
>(),
51 gfx::Rect(0, 0, 400, 1100));
52 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
53 EXPECT_EQ(250, page_content
.x());
54 EXPECT_EQ(250, page_content
.y());
55 EXPECT_EQ(400, page_content
.width());
56 EXPECT_EQ(1100, page_content
.height());
60 TEST(PrintedPageTest
, Shrink
) {
61 scoped_refptr
<PrintedPage
> page
=
63 scoped_ptr
<MetafilePlayer
>(),
64 gfx::Size(1200, 1200),
65 gfx::Rect(0, 0, 400, 1100));
66 EXPECT_EQ(0.0f
, page
->shrink_factor());
67 page
->set_shrink_factor(0.2f
);
68 EXPECT_EQ(0.2f
, page
->shrink_factor());
69 page
->set_shrink_factor(0.7f
);
70 EXPECT_EQ(0.7f
, page
->shrink_factor());
74 } // namespace printing