OLD | NEW |
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/string16.h" |
6 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" |
7 #include "printing/page_overlays.h" | 9 #include "printing/page_overlays.h" |
8 #include "printing/print_settings.h" | 10 #include "printing/print_settings.h" |
9 #include "printing/printed_document.h" | 11 #include "printing/printed_document.h" |
10 #include "printing/printed_page.h" | 12 #include "printing/printed_page.h" |
11 #include "printing/printed_pages_source.h" | 13 #include "printing/printed_pages_source.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 struct Keys { | 18 struct Keys { |
17 const wchar_t* key; | 19 const wchar_t* key; |
18 const wchar_t* expected; | 20 const wchar_t* expected; |
19 }; | 21 }; |
20 | 22 |
21 const Keys kOverlayKeys[] = { | 23 const Keys kOverlayKeys[] = { |
22 { printing::PageOverlays::kTitle, L"Foobar Document" }, | 24 { printing::PageOverlays::kTitle, L"Foobar Document" }, |
23 { printing::PageOverlays::kTime, L"" }, | 25 { printing::PageOverlays::kTime, L"" }, |
24 { printing::PageOverlays::kDate, L"" }, | 26 { printing::PageOverlays::kDate, L"" }, |
25 { printing::PageOverlays::kPage, L"1" }, | 27 { printing::PageOverlays::kPage, L"1" }, |
26 { printing::PageOverlays::kPageCount, L"2" }, | 28 { printing::PageOverlays::kPageCount, L"2" }, |
27 { printing::PageOverlays::kPageOnTotal, L"1/2" }, | 29 { printing::PageOverlays::kPageOnTotal, L"1/2" }, |
28 { printing::PageOverlays::kUrl, L"http://www.perdu.com/" }, | 30 { printing::PageOverlays::kUrl, L"http://www.perdu.com/" }, |
29 }; | 31 }; |
30 | 32 |
31 class PagesSource : public printing::PrintedPagesSource { | 33 class PagesSource : public printing::PrintedPagesSource { |
32 public: | 34 public: |
33 virtual std::wstring RenderSourceName() { | 35 virtual string16 RenderSourceName() { |
34 return L"Foobar Document"; | 36 return ASCIIToUTF16("Foobar Document"); |
35 } | 37 } |
36 | 38 |
37 virtual GURL RenderSourceUrl() { | 39 virtual GURL RenderSourceUrl() { |
38 return GURL("http://www.perdu.com"); | 40 return GURL("http://www.perdu.com"); |
39 } | 41 } |
40 }; | 42 }; |
41 | 43 |
42 } // namespace | 44 } // namespace |
43 | 45 |
44 class PageOverlaysTest : public testing::Test { | 46 class PageOverlaysTest : public testing::Test { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 L"Page {page}"); | 83 L"Page {page}"); |
82 input = overlays.GetOverlay(printing::PageOverlays::LEFT, | 84 input = overlays.GetOverlay(printing::PageOverlays::LEFT, |
83 printing::PageOverlays::TOP); | 85 printing::PageOverlays::TOP); |
84 EXPECT_EQ(input, L"Page {page}"); | 86 EXPECT_EQ(input, L"Page {page}"); |
85 | 87 |
86 // Replace the variables to see if the page number is correct. | 88 // Replace the variables to see if the page number is correct. |
87 out = printing::PageOverlays::ReplaceVariables(input, *doc.get(), | 89 out = printing::PageOverlays::ReplaceVariables(input, *doc.get(), |
88 *page.get()); | 90 *page.get()); |
89 EXPECT_EQ(out, L"Page 1"); | 91 EXPECT_EQ(out, L"Page 1"); |
90 } | 92 } |
OLD | NEW |