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

Side by Side Diff: printing/page_overlays_unittest.cc

Issue 2859040: Implement limited paged media support for win. (Closed)
Patch Set: the comment fix Created 10 years, 5 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
« no previous file with comments | « chrome/renderer/print_web_view_helper_win.cc ('k') | printing/printed_document.h » ('j') | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "printing/page_overlays.h" 7 #include "printing/page_overlays.h"
8 #include "printing/print_settings.h" 8 #include "printing/print_settings.h"
9 #include "printing/printed_document.h" 9 #include "printing/printed_document.h"
10 #include "printing/printed_page.h" 10 #include "printing/printed_page.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 printing::PageOverlays::BOTTOM); 52 printing::PageOverlays::BOTTOM);
53 printing::PrintSettings settings; 53 printing::PrintSettings settings;
54 PagesSource source; 54 PagesSource source;
55 int cookie = 1; 55 int cookie = 1;
56 scoped_refptr<printing::PrintedDocument> doc( 56 scoped_refptr<printing::PrintedDocument> doc(
57 new printing::PrintedDocument(settings, &source, cookie)); 57 new printing::PrintedDocument(settings, &source, cookie));
58 doc->set_page_count(2); 58 doc->set_page_count(2);
59 gfx::Size page_size(100, 100); 59 gfx::Size page_size(100, 100);
60 gfx::Rect page_content_area(5, 5, 90, 90); 60 gfx::Rect page_content_area(5, 5, 90, 90);
61 scoped_refptr<printing::PrintedPage> page( 61 scoped_refptr<printing::PrintedPage> page(
62 new printing::PrintedPage(1, NULL, page_size, page_content_area)); 62 new printing::PrintedPage(1, NULL, page_size, page_content_area, true));
63 63
64 std::wstring input; 64 std::wstring input;
65 std::wstring out; 65 std::wstring out;
66 for (size_t i = 0; i < arraysize(kOverlayKeys); ++i) { 66 for (size_t i = 0; i < arraysize(kOverlayKeys); ++i) {
67 input = StringPrintf(L"foo%lsbar", kOverlayKeys[i].key); 67 input = StringPrintf(L"foo%lsbar", kOverlayKeys[i].key);
68 out = printing::PageOverlays::ReplaceVariables(input, *doc.get(), 68 out = printing::PageOverlays::ReplaceVariables(input, *doc.get(),
69 *page.get()); 69 *page.get());
70 EXPECT_FALSE(out.empty()); 70 EXPECT_FALSE(out.empty());
71 if (wcslen(kOverlayKeys[i].expected) == 0) 71 if (wcslen(kOverlayKeys[i].expected) == 0)
72 continue; 72 continue;
73 std::wstring expected = StringPrintf(L"foo%lsbar", 73 std::wstring expected = StringPrintf(L"foo%lsbar",
74 kOverlayKeys[i].expected); 74 kOverlayKeys[i].expected);
75 EXPECT_EQ(expected, out) << kOverlayKeys[i].key; 75 EXPECT_EQ(expected, out) << kOverlayKeys[i].key;
76 } 76 }
77 77
78 // Check if SetOverlay really sets the page overlay. 78 // Check if SetOverlay really sets the page overlay.
79 overlays.SetOverlay(printing::PageOverlays::LEFT, 79 overlays.SetOverlay(printing::PageOverlays::LEFT,
80 printing::PageOverlays::TOP, 80 printing::PageOverlays::TOP,
81 L"Page {page}"); 81 L"Page {page}");
82 input = overlays.GetOverlay(printing::PageOverlays::LEFT, 82 input = overlays.GetOverlay(printing::PageOverlays::LEFT,
83 printing::PageOverlays::TOP); 83 printing::PageOverlays::TOP);
84 EXPECT_EQ(input, L"Page {page}"); 84 EXPECT_EQ(input, L"Page {page}");
85 85
86 // Replace the variables to see if the page number is correct. 86 // Replace the variables to see if the page number is correct.
87 out = printing::PageOverlays::ReplaceVariables(input, *doc.get(), 87 out = printing::PageOverlays::ReplaceVariables(input, *doc.get(),
88 *page.get()); 88 *page.get());
89 EXPECT_EQ(out, L"Page 1"); 89 EXPECT_EQ(out, L"Page 1");
90 } 90 }
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper_win.cc ('k') | printing/printed_document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698