OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.distiller; | |
6 | |
7 public class PageParameterDetectorTest extends DomDistillerJsTestCase { | |
8 | |
9 public void testIsLastNumericPathComponentBad() { | |
10 // Path component is not numeric i.e. contains non-digits. | |
11 String url = "http://www.foo.com/a2"; | |
12 int digitStart = url.indexOf("2"); | |
13 assertFalse(PageParameterDetector.isLastNumericPathComponentBad(url, 18,
digitStart, | |
14 digitStart + 1)); | |
15 | |
16 // Numeric path component is first. | |
17 url = "http://www.foo.com/2"; | |
18 digitStart = url.indexOf("2"); | |
19 assertFalse(PageParameterDetector.isLastNumericPathComponentBad(url, 18,
digitStart, | |
20 digitStart + 1)); | |
21 | |
22 // Numeric path component follows a path component that is not a bad pag
e param name. | |
23 url = "http://www.foo.com/good/2"; | |
24 digitStart = url.indexOf("2"); | |
25 assertFalse(PageParameterDetector.isLastNumericPathComponentBad(url, 18,
digitStart, | |
26 digitStart + 1)); | |
27 | |
28 // Numeric path component follows a path component that is a bad page pa
ram name. | |
29 url = "http://www.foo.com/wiki/2"; | |
30 digitStart = url.indexOf("2"); | |
31 assertTrue(PageParameterDetector.isLastNumericPathComponentBad(url, 18,
digitStart, | |
32 digitStart + 1)); | |
33 | |
34 // (s)htm(l) extension doesn't follow digit. | |
35 url = "http://www.foo.com/2a"; | |
36 digitStart = url.indexOf("2"); | |
37 assertFalse(PageParameterDetector.isLastNumericPathComponentBad(url, 18,
digitStart, | |
38 digitStart + 1)); | |
39 | |
40 // .htm follows digit, previous path component is not a bad page param n
ame. | |
41 url = "http://www.foo.com/good/2.htm"; | |
42 digitStart = url.indexOf("2"); | |
43 assertFalse(PageParameterDetector.isLastNumericPathComponentBad(url, 18,
digitStart, | |
44 digitStart + 1)); | |
45 | |
46 // .html follows digit, previous path component is a bad page param name
. | |
47 url = "http://www.foo.com/wiki/2.html"; | |
48 digitStart = url.indexOf("2"); | |
49 assertTrue(PageParameterDetector.isLastNumericPathComponentBad(url, 18,
digitStart, | |
50 digitStart + 1)); | |
51 | |
52 // .shtml follows digit, previous path component is not a bad page param
name, but the one | |
53 // before that is. | |
54 url = "http://www.foo.com/wiki/good/2.shtml"; | |
55 digitStart = url.indexOf("2"); | |
56 assertFalse(PageParameterDetector.isLastNumericPathComponentBad(url, 18,
digitStart, | |
57 digitStart + 1)); | |
58 } | |
59 | |
60 } | |
OLD | NEW |