Misc clean up in browser_shutdown.cc.
[chromium-blink-merge.git] / printing / printed_page_unittest.cc
blob795afe48771b6c7651a2582ff86d560554767cf4
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"
8 namespace printing {
10 TEST(PrintedPageTest, GetCenteredPageContentRect) {
11 scoped_refptr<PrintedPage> page;
12 gfx::Rect page_content;
14 // No centering.
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());
25 // X centered.
26 page = new PrintedPage(1,
27 scoped_ptr<MetafilePlayer>(),
28 gfx::Size(500, 1200),
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());
36 // Y centered.
37 page = new PrintedPage(1,
38 scoped_ptr<MetafilePlayer>(),
39 gfx::Size(1200, 500),
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>(),
50 gfx::Size(500, 500),
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());
59 #if defined(OS_WIN)
60 TEST(PrintedPageTest, Shrink) {
61 scoped_refptr<PrintedPage> page =
62 new PrintedPage(1,
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());
72 #endif // OS_WIN
74 } // namespace printing