| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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 "chrome/browser/printing/page_overlays.h" | 7 #include "chrome/browser/printing/page_overlays.h" |
| 8 #include "chrome/browser/printing/print_settings.h" | 8 #include "chrome/browser/printing/print_settings.h" |
| 9 #include "chrome/browser/printing/printed_document.h" | 9 #include "chrome/browser/printing/printed_document.h" |
| 10 #include "chrome/browser/printing/printed_page.h" | 10 #include "chrome/browser/printing/printed_page.h" |
| 11 #include "chrome/browser/printing/printed_pages_source.h" | 11 #include "chrome/browser/printing/printed_pages_source.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 for (int i = 0; i < arraysize(kOverlayKeys); ++i) { | 66 for (int 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 EXPECT_EQ(StringPrintf(L"foo%lsbar", kOverlayKeys[i].expected), out) << | 73 EXPECT_EQ(StringPrintf(L"foo%lsbar", kOverlayKeys[i].expected), out) << |
| 74 kOverlayKeys[i].key; | 74 kOverlayKeys[i].key; |
| 75 } | 75 } |
| 76 |
| 77 // Check if SetOverlay really sets the page overlay. |
| 78 overlays.SetOverlay(printing::PageOverlays::LEFT, |
| 79 printing::PageOverlays::TOP, |
| 80 UTF16ToWide(L"Page {page}")); |
| 81 input = overlays.GetOverlay(printing::PageOverlays::LEFT, |
| 82 printing::PageOverlays::TOP); |
| 83 EXPECT_EQ(input, L"Page {page}"); |
| 84 |
| 85 // Replace the variables to see if the page number is correct. |
| 86 out = printing::PageOverlays::ReplaceVariables(input, *doc.get(), |
| 87 *page.get()); |
| 88 EXPECT_EQ(out, L"Page 1"); |
| 76 } | 89 } |
| OLD | NEW |