OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 package org.chromium.distiller; | 5 package org.chromium.distiller; |
6 | 6 |
7 import com.google.gwt.dom.client.Element; | 7 import com.google.gwt.dom.client.Element; |
8 | 8 |
9 public class DocumentTitleGetterTest extends DomDistillerJsTestCase { | 9 public class DocumentTitleGetterTest extends DomDistillerJsTestCase { |
10 public void testNonStringWithoutRoot() { | 10 public void testNonStringWithoutRoot() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 "before dash - after dash", null); | 52 "before dash - after dash", null); |
53 assertEquals("before dash - after dash", title); | 53 assertEquals("before dash - after dash", title); |
54 } | 54 } |
55 | 55 |
56 public void test1Dash2LongParts() { | 56 public void test1Dash2LongParts() { |
57 String title = DocumentTitleGetter.getDocumentTitle( | 57 String title = DocumentTitleGetter.getDocumentTitle( |
58 "part with 6 words before dash - part with 6 words after dash",
null); | 58 "part with 6 words before dash - part with 6 words after dash",
null); |
59 assertEquals("part with 6 words before dash", title); | 59 assertEquals("part with 6 words before dash", title); |
60 } | 60 } |
61 | 61 |
| 62 public void test1Dash2LongPartsChinese() { |
| 63 String title = DocumentTitleGetter.getDocumentTitle( |
| 64 "比較長一點的句子 - 這是不要的部分", null); |
| 65 assertEquals("比較長一點的句子", title); |
| 66 } |
| 67 |
62 public void test1DashLongAndShortParts() { | 68 public void test1DashLongAndShortParts() { |
63 String title = DocumentTitleGetter.getDocumentTitle( | 69 String title = DocumentTitleGetter.getDocumentTitle( |
64 "part with 6 words before dash - after dash", null); | 70 "part with 6 words before dash - after dash", null); |
65 assertEquals("part with 6 words before dash", title); | 71 assertEquals("part with 6 words before dash", title); |
66 } | 72 } |
67 | 73 |
68 public void test1DashShortAndLongParts() { | 74 public void test1DashShortAndLongParts() { |
69 // TODO(kuan): if using RegExp.split, this fails with "ant test.prod". | |
70 String title = DocumentTitleGetter.getDocumentTitle( | 75 String title = DocumentTitleGetter.getDocumentTitle( |
71 "before dash - part with 6 words after dash", null); | 76 "before dash - part with 6 words after dash", null); |
72 assertEquals("part with 6 words after dash", title); | 77 assertEquals("part with 6 words after dash", title); |
73 } | 78 } |
74 | 79 |
| 80 public void test1DashShortAndLongPartsChinese() { |
| 81 String title = DocumentTitleGetter.getDocumentTitle( |
| 82 "短語 - 比較長一點的句子", null); |
| 83 assertEquals("比較長一點的句子", title); |
| 84 } |
| 85 |
75 public void test2DashesShortParts() { | 86 public void test2DashesShortParts() { |
76 String title = DocumentTitleGetter.getDocumentTitle( | 87 String title = DocumentTitleGetter.getDocumentTitle( |
77 "before dash - between dash0 and dash1 - after dash1", null); | 88 "before dash - between dash0 and dash1 - after dash1", null); |
78 assertEquals("before dash - between dash0 and dash1", title); | 89 assertEquals("before dash - between dash0 and dash1", title); |
79 } | 90 } |
80 | 91 |
81 public void test2DashesShortAndLongParts() { | 92 public void test2DashesShortAndLongParts() { |
82 // TODO(kuan): if using RegExp.split, this fails with "ant test.prod". | 93 // TODO(kuan): if using RegExp.split, this fails with "ant test.prod". |
83 String title = DocumentTitleGetter.getDocumentTitle( | 94 String title = DocumentTitleGetter.getDocumentTitle( |
84 "before - - part with 6 words after dash", null); | 95 "before - - part with 6 words after dash", null); |
85 assertEquals("- part with 6 words after dash", title); | 96 assertEquals("- part with 6 words after dash", title); |
86 } | 97 } |
87 | 98 |
88 public void test1Bar2ShortParts() { | 99 public void test1Bar2ShortParts() { |
89 String title = DocumentTitleGetter.getDocumentTitle( | 100 String title = DocumentTitleGetter.getDocumentTitle( |
90 "before bar | after bar", null); | 101 "before bar | after bar", null); |
91 assertEquals("before bar | after bar", title); | 102 assertEquals("before bar | after bar", title); |
92 } | 103 } |
93 | 104 |
94 public void test2ColonsShortParts() { | 105 public void test2ColonsShortParts() { |
95 String title = DocumentTitleGetter.getDocumentTitle( | 106 String title = DocumentTitleGetter.getDocumentTitle( |
96 "start : midway : end", null); | 107 "start : midway : end", null); |
97 assertEquals("start : midway : end", title); | 108 assertEquals("start : midway : end", title); |
98 } | 109 } |
99 | 110 |
| 111 public void test2ColonsShortPartsChinese() { |
| 112 String title = DocumentTitleGetter.getDocumentTitle( |
| 113 "開始 : 中間 : 最後", null); |
| 114 assertEquals("開始 : 中間 : 最後", title); |
| 115 } |
| 116 |
100 public void test2ColonsShortAndLongParts() { | 117 public void test2ColonsShortAndLongParts() { |
101 String title = DocumentTitleGetter.getDocumentTitle( | 118 String title = DocumentTitleGetter.getDocumentTitle( |
102 "start : midway : part with 6 words at end", null); | 119 "start : midway : part with 6 words at end", null); |
103 assertEquals("part with 6 words at end", title); | 120 assertEquals("part with 6 words at end", title); |
104 } | 121 } |
105 | 122 |
| 123 public void test2ColonsShortAndLongPartsChinese() { |
| 124 String title = DocumentTitleGetter.getDocumentTitle( |
| 125 "開始 : 中間 : 最後比較長的部分", null); |
| 126 assertEquals("最後比較長的部分", title); |
| 127 } |
| 128 |
106 public void test2ColonsShortAndLongAndShortParts() { | 129 public void test2ColonsShortAndLongAndShortParts() { |
107 String title = DocumentTitleGetter.getDocumentTitle( | 130 String title = DocumentTitleGetter.getDocumentTitle( |
108 "start : part with 6 words at midway : end", null); | 131 "start : part with 6 words at midway : end", null); |
109 assertEquals("part with 6 words at midway : end", title); | 132 assertEquals("part with 6 words at midway : end", title); |
110 } | 133 } |
111 | 134 |
| 135 public void test2ColonsShortAndLongAndShortPartsChinese() { |
| 136 String title = DocumentTitleGetter.getDocumentTitle( |
| 137 "開始 : 中間要的部分 : 最後", null); |
| 138 assertEquals("中間要的部分 : 最後", title); |
| 139 } |
| 140 |
112 public void testH1WithShortText() { | 141 public void testH1WithShortText() { |
113 Element root = TestUtil.createDiv(0); | 142 Element root = TestUtil.createDiv(0); |
114 Element h1 = TestUtil.createHeading(1, "short heading"); | 143 Element h1 = TestUtil.createHeading(1, "short heading"); |
115 root.appendChild(h1); | 144 root.appendChild(h1); |
116 | 145 |
117 String title = DocumentTitleGetter.getDocumentTitle("short title", root)
; | 146 String title = DocumentTitleGetter.getDocumentTitle("short title", root)
; |
118 assertEquals("short title", title); | 147 assertEquals("short title", title); |
119 } | 148 } |
120 | 149 |
121 public void testH1WithLongText() { | 150 public void testH1WithLongText() { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 String title = DocumentTitleGetter.getDocumentTitle("short title", null)
; | 191 String title = DocumentTitleGetter.getDocumentTitle("short title", null)
; |
163 assertEquals("short title", title); | 192 assertEquals("short title", title); |
164 } | 193 } |
165 | 194 |
166 public void testShortTitleWithoutH1() { | 195 public void testShortTitleWithoutH1() { |
167 Element root = TestUtil.createDiv(0); | 196 Element root = TestUtil.createDiv(0); |
168 String title = DocumentTitleGetter.getDocumentTitle("short title", root)
; | 197 String title = DocumentTitleGetter.getDocumentTitle("short title", root)
; |
169 assertEquals("short title", title); | 198 assertEquals("short title", title); |
170 } | 199 } |
171 } | 200 } |
OLD | NEW |