forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PrintedPage::GetCenteredPageContentRect so Mac and Win can share …
…code. BUG=47277 TEST=printed_page_unittest Review URL: http://codereview.chromium.org/2878022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51626 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
hamaji@chromium.org
committed
Jul 5, 2010
1 parent
1322d87
commit a12552b
Showing
6 changed files
with
91 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) 2010 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "printing/printed_page.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace printing { | ||
|
||
TEST(PrintedPageTest, GetCenteredPageContentRect) { | ||
scoped_refptr<PrintedPage> page; | ||
gfx::Rect page_content; | ||
|
||
// No centering. | ||
page =new PrintedPage(1, | ||
NULL, | ||
gfx::Size(1200, 1200), | ||
gfx::Rect(0, 0, 400, 1100), | ||
true); | ||
page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); | ||
EXPECT_EQ(0, page_content.x()); | ||
EXPECT_EQ(0, page_content.y()); | ||
EXPECT_EQ(400, page_content.width()); | ||
EXPECT_EQ(1100, page_content.height()); | ||
|
||
// X centered. | ||
page = new PrintedPage(1, | ||
NULL, | ||
gfx::Size(500, 1200), | ||
gfx::Rect(0, 0, 400, 1100), | ||
true); | ||
page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); | ||
EXPECT_EQ(250, page_content.x()); | ||
EXPECT_EQ(0, page_content.y()); | ||
EXPECT_EQ(400, page_content.width()); | ||
EXPECT_EQ(1100, page_content.height()); | ||
|
||
// Y centered. | ||
page = new PrintedPage(1, | ||
NULL, | ||
gfx::Size(1200, 500), | ||
gfx::Rect(0, 0, 400, 1100), | ||
true); | ||
page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); | ||
EXPECT_EQ(0, page_content.x()); | ||
EXPECT_EQ(250, page_content.y()); | ||
EXPECT_EQ(400, page_content.width()); | ||
EXPECT_EQ(1100, page_content.height()); | ||
|
||
// Both X and Y centered. | ||
page = new PrintedPage(1, | ||
NULL, | ||
gfx::Size(500, 500), | ||
gfx::Rect(0, 0, 400, 1100), | ||
true); | ||
page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content); | ||
EXPECT_EQ(250, page_content.x()); | ||
EXPECT_EQ(250, page_content.y()); | ||
EXPECT_EQ(400, page_content.width()); | ||
EXPECT_EQ(1100, page_content.height()); | ||
} | ||
|
||
} // namespace printing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters