Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: printing/printed_page_unittest.cc

Issue 335473002: Guarded shrink setting with ifdefs to make clear where it is used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Thu 06/12/2014 0:59:45.49 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/printed_page.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/printed_page.h" 5 #include "printing/printed_page.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace printing { 8 namespace printing {
9 9
10 TEST(PrintedPageTest, GetCenteredPageContentRect) { 10 TEST(PrintedPageTest, GetCenteredPageContentRect) {
11 scoped_refptr<PrintedPage> page; 11 scoped_refptr<PrintedPage> page;
12 gfx::Rect page_content; 12 gfx::Rect page_content;
13 13
14 // No centering. 14 // No centering.
15 page = new PrintedPage(1, 15 page = new PrintedPage(
16 NULL, 16 1, NULL, gfx::Size(1200, 1200), gfx::Rect(0, 0, 400, 1100));
17 gfx::Size(1200, 1200),
18 gfx::Rect(0, 0, 400, 1100),
19 0.2f);
20 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); 17 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
21 EXPECT_EQ(0, page_content.x()); 18 EXPECT_EQ(0, page_content.x());
22 EXPECT_EQ(0, page_content.y()); 19 EXPECT_EQ(0, page_content.y());
23 EXPECT_EQ(400, page_content.width()); 20 EXPECT_EQ(400, page_content.width());
24 EXPECT_EQ(1100, page_content.height()); 21 EXPECT_EQ(1100, page_content.height());
25 EXPECT_EQ(0.2f, page->shrink_factor());
26 22
27 // X centered. 23 // X centered.
28 page = new PrintedPage(1, 24 page = new PrintedPage(
29 NULL, 25 1, NULL, gfx::Size(500, 1200), gfx::Rect(0, 0, 400, 1100));
30 gfx::Size(500, 1200),
31 gfx::Rect(0, 0, 400, 1100),
32 0.8f);
33 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); 26 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
34 EXPECT_EQ(250, page_content.x()); 27 EXPECT_EQ(250, page_content.x());
35 EXPECT_EQ(0, page_content.y()); 28 EXPECT_EQ(0, page_content.y());
36 EXPECT_EQ(400, page_content.width()); 29 EXPECT_EQ(400, page_content.width());
37 EXPECT_EQ(1100, page_content.height()); 30 EXPECT_EQ(1100, page_content.height());
38 EXPECT_EQ(0.8f, page->shrink_factor());
39 31
40 // Y centered. 32 // Y centered.
41 page = new PrintedPage(1, 33 page = new PrintedPage(
42 NULL, 34 1, NULL, gfx::Size(1200, 500), gfx::Rect(0, 0, 400, 1100));
43 gfx::Size(1200, 500),
44 gfx::Rect(0, 0, 400, 1100),
45 1.0f);
46 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); 35 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
47 EXPECT_EQ(0, page_content.x()); 36 EXPECT_EQ(0, page_content.x());
48 EXPECT_EQ(250, page_content.y()); 37 EXPECT_EQ(250, page_content.y());
49 EXPECT_EQ(400, page_content.width()); 38 EXPECT_EQ(400, page_content.width());
50 EXPECT_EQ(1100, page_content.height()); 39 EXPECT_EQ(1100, page_content.height());
51 EXPECT_EQ(1.0f, page->shrink_factor());
52 40
53 // Both X and Y centered. 41 // Both X and Y centered.
54 page = new PrintedPage(1, 42 page =
55 NULL, 43 new PrintedPage(1, NULL, gfx::Size(500, 500), gfx::Rect(0, 0, 400, 1100));
56 gfx::Size(500, 500),
57 gfx::Rect(0, 0, 400, 1100),
58 0.3f);
59 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); 44 page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
60 EXPECT_EQ(250, page_content.x()); 45 EXPECT_EQ(250, page_content.x());
61 EXPECT_EQ(250, page_content.y()); 46 EXPECT_EQ(250, page_content.y());
62 EXPECT_EQ(400, page_content.width()); 47 EXPECT_EQ(400, page_content.width());
63 EXPECT_EQ(1100, page_content.height()); 48 EXPECT_EQ(1100, page_content.height());
64 EXPECT_EQ(0.3f, page->shrink_factor());
65 } 49 }
66 50
51 #if defined(OS_WIN)
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());
60 }
61 #endif // OS_WIN
62
67 } // namespace printing 63 } // namespace printing
OLDNEW
« no previous file with comments | « printing/printed_page.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698