1 // Copyright (c) 2010 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"
10 #include "testing/gtest/include/gtest/gtest.h"
14 TEST(PrintedPageTest
, GetCenteredPageContentRect
) {
15 scoped_refptr
<PrintedPage
> page
;
16 gfx::Rect page_content
;
19 page
=new PrintedPage(1,
21 gfx::Size(1200, 1200),
22 gfx::Rect(0, 0, 400, 1100),
24 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
25 EXPECT_EQ(0, page_content
.x());
26 EXPECT_EQ(0, page_content
.y());
27 EXPECT_EQ(400, page_content
.width());
28 EXPECT_EQ(1100, page_content
.height());
31 page
= new PrintedPage(1,
34 gfx::Rect(0, 0, 400, 1100),
36 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
37 EXPECT_EQ(250, page_content
.x());
38 EXPECT_EQ(0, page_content
.y());
39 EXPECT_EQ(400, page_content
.width());
40 EXPECT_EQ(1100, page_content
.height());
43 page
= new PrintedPage(1,
46 gfx::Rect(0, 0, 400, 1100),
48 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
49 EXPECT_EQ(0, page_content
.x());
50 EXPECT_EQ(250, page_content
.y());
51 EXPECT_EQ(400, page_content
.width());
52 EXPECT_EQ(1100, page_content
.height());
54 // Both X and Y centered.
55 page
= new PrintedPage(1,
58 gfx::Rect(0, 0, 400, 1100),
60 page
->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content
);
61 EXPECT_EQ(250, page_content
.x());
62 EXPECT_EQ(250, page_content
.y());
63 EXPECT_EQ(400, page_content
.width());
64 EXPECT_EQ(1100, page_content
.height());
67 } // namespace printing