[GCM] Adding retry logic to registration
[chromium-blink-merge.git] / printing / printed_page_unittest.cc
blob9cce52a1cb831640511f485b25b1b82f3c76a060
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 NULL,
17 gfx::Size(1200, 1200),
18 gfx::Rect(0, 0, 400, 1100),
19 0.2f);
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());
27 // X centered.
28 page = new PrintedPage(1,
29 NULL,
30 gfx::Size(500, 1200),
31 gfx::Rect(0, 0, 400, 1100),
32 0.8f);
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());
40 // Y centered.
41 page = new PrintedPage(1,
42 NULL,
43 gfx::Size(1200, 500),
44 gfx::Rect(0, 0, 400, 1100),
45 1.0f);
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,
55 NULL,
56 gfx::Size(500, 500),
57 gfx::Rect(0, 0, 400, 1100),
58 0.3f);
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