OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013, the Dart project authors. | 2 * Copyright (c) 2013, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express |
(...skipping 14 matching lines...) Expand all Loading... | |
25 | 25 |
26 public class HtmlEntryImplTest extends EngineTestCase { | 26 public class HtmlEntryImplTest extends EngineTestCase { |
27 public void test_creation() { | 27 public void test_creation() { |
28 HtmlEntryImpl entry = new HtmlEntryImpl(); | 28 HtmlEntryImpl entry = new HtmlEntryImpl(); |
29 assertNotNull(entry); | 29 assertNotNull(entry); |
30 } | 30 } |
31 | 31 |
32 public void test_getAllErrors() { | 32 public void test_getAllErrors() { |
33 Source source = new TestSource(); | 33 Source source = new TestSource(); |
34 HtmlEntryImpl entry = new HtmlEntryImpl(); | 34 HtmlEntryImpl entry = new HtmlEntryImpl(); |
35 assertLength(0, entry.getAllErrors()); | 35 assertLength(0, entry.getAllErrors()); |
danrubel
2013/11/25 02:26:12
add a parse error here and validate here to assert
| |
36 entry.setValue(HtmlEntry.RESOLUTION_ERRORS, new AnalysisError[] {new Analysi sError( | 36 entry.setValue(HtmlEntry.RESOLUTION_ERRORS, new AnalysisError[] {new Analysi sError( |
37 source, | 37 source, |
38 HtmlWarningCode.INVALID_URI, | 38 HtmlWarningCode.INVALID_URI, |
39 "-")}); | 39 "-")}); |
40 entry.setValue(HtmlEntry.HINTS, new AnalysisError[] {new AnalysisError( | 40 entry.setValue(HtmlEntry.HINTS, new AnalysisError[] {new AnalysisError( |
41 source, | 41 source, |
42 HintCode.DEAD_CODE)}); | 42 HintCode.DEAD_CODE)}); |
43 assertLength(2, entry.getAllErrors()); | 43 assertLength(2, entry.getAllErrors()); |
44 } | 44 } |
45 | 45 |
46 public void test_getWritableCopy() { | 46 public void test_getWritableCopy() { |
47 HtmlEntryImpl entry = new HtmlEntryImpl(); | 47 HtmlEntryImpl entry = new HtmlEntryImpl(); |
48 HtmlEntryImpl copy = entry.getWritableCopy(); | 48 HtmlEntryImpl copy = entry.getWritableCopy(); |
49 assertNotNull(copy); | 49 assertNotNull(copy); |
50 assertNotSame(entry, copy); | 50 assertNotSame(entry, copy); |
51 } | 51 } |
52 | 52 |
53 public void test_invalidateAllResolutionInformation() { | 53 public void test_invalidateAllResolutionInformation() { |
54 HtmlEntryImpl entry = entryWithValidState(); | 54 HtmlEntryImpl entry = entryWithValidState(); |
55 entry.invalidateAllResolutionInformation(); | 55 entry.invalidateAllResolutionInformation(); |
56 assertSame(CacheState.INVALID, entry.getState(HtmlEntry.ELEMENT)); | 56 assertSame(CacheState.INVALID, entry.getState(HtmlEntry.ELEMENT)); |
57 assertSame(CacheState.INVALID, entry.getState(HtmlEntry.HINTS)); | 57 assertSame(CacheState.INVALID, entry.getState(HtmlEntry.HINTS)); |
58 assertSame(CacheState.VALID, entry.getState(SourceEntry.LINE_INFO)); | 58 assertSame(CacheState.VALID, entry.getState(SourceEntry.LINE_INFO)); |
59 assertSame(CacheState.VALID, entry.getState(HtmlEntry.PARSED_UNIT)); | 59 assertSame(CacheState.VALID, entry.getState(HtmlEntry.PARSED_UNIT)); |
60 assertSame(CacheState.VALID, entry.getState(HtmlEntry.REFERENCED_LIBRARIES)) ; | 60 assertSame(CacheState.VALID, entry.getState(HtmlEntry.REFERENCED_LIBRARIES)) ; |
61 assertSame(CacheState.INVALID, entry.getState(HtmlEntry.RESOLUTION_ERRORS)); | 61 assertSame(CacheState.INVALID, entry.getState(HtmlEntry.RESOLUTION_ERRORS)); |
danrubel
2013/11/25 02:26:12
assertSame(CacheState.VALID, entry.getState(HtmlEn
Brian Wilkerson
2013/11/25 19:04:36
Done
| |
62 } | 62 } |
63 | 63 |
64 public void test_setState_element() { | 64 public void test_setState_element() { |
65 setState(HtmlEntry.ELEMENT); | 65 setState(HtmlEntry.ELEMENT); |
66 } | 66 } |
67 | 67 |
68 public void test_setState_hints() { | 68 public void test_setState_hints() { |
69 setState(HtmlEntry.HINTS); | 69 setState(HtmlEntry.HINTS); |
70 } | 70 } |
71 | 71 |
72 public void test_setState_lineInfo() { | 72 public void test_setState_lineInfo() { |
73 setState(SourceEntry.LINE_INFO); | 73 setState(SourceEntry.LINE_INFO); |
74 } | 74 } |
75 | 75 |
76 public void test_setState_parsedUnit() { | 76 public void test_setState_parsedUnit() { |
77 setState(HtmlEntry.PARSED_UNIT); | 77 setState(HtmlEntry.PARSED_UNIT); |
78 } | 78 } |
79 | 79 |
80 public void test_setState_parseErrors() { | |
81 setState(HtmlEntry.PARSE_ERRORS); | |
82 } | |
83 | |
80 public void test_setState_referencedLibraries() { | 84 public void test_setState_referencedLibraries() { |
81 setState(HtmlEntry.REFERENCED_LIBRARIES); | 85 setState(HtmlEntry.REFERENCED_LIBRARIES); |
82 } | 86 } |
83 | 87 |
84 public void test_setState_resolutionErrors() { | 88 public void test_setState_resolutionErrors() { |
85 setState(HtmlEntry.RESOLUTION_ERRORS); | 89 setState(HtmlEntry.RESOLUTION_ERRORS); |
86 } | 90 } |
87 | 91 |
88 public void test_setValue_element() { | 92 public void test_setValue_element() { |
89 setValue(HtmlEntry.ELEMENT, new HtmlElementImpl(null, "test.html")); | 93 setValue(HtmlEntry.ELEMENT, new HtmlElementImpl(null, "test.html")); |
(...skipping 14 matching lines...) Expand all Loading... | |
104 } | 108 } |
105 | 109 |
106 public void test_setValue_lineInfo() { | 110 public void test_setValue_lineInfo() { |
107 setValue(SourceEntry.LINE_INFO, new LineInfo(new int[] {0})); | 111 setValue(SourceEntry.LINE_INFO, new LineInfo(new int[] {0})); |
108 } | 112 } |
109 | 113 |
110 public void test_setValue_parsedUnit() { | 114 public void test_setValue_parsedUnit() { |
111 setValue(HtmlEntry.PARSED_UNIT, new HtmlUnit(null, null, null)); | 115 setValue(HtmlEntry.PARSED_UNIT, new HtmlUnit(null, null, null)); |
112 } | 116 } |
113 | 117 |
118 public void test_setValue_parseErrors() { | |
119 setValue(HtmlEntry.PARSE_ERRORS, new AnalysisError[] {new AnalysisError( | |
120 null, | |
121 HtmlWarningCode.INVALID_URI, | |
122 "-")}); | |
123 } | |
124 | |
114 public void test_setValue_referencedLibraries() { | 125 public void test_setValue_referencedLibraries() { |
115 setValue(HtmlEntry.REFERENCED_LIBRARIES, new Source[] {new TestSource()}); | 126 setValue(HtmlEntry.REFERENCED_LIBRARIES, new Source[] {new TestSource()}); |
116 } | 127 } |
117 | 128 |
118 public void test_setValue_resolutionErrors() { | 129 public void test_setValue_resolutionErrors() { |
119 setValue(HtmlEntry.RESOLUTION_ERRORS, new AnalysisError[] {new AnalysisError ( | 130 setValue(HtmlEntry.RESOLUTION_ERRORS, new AnalysisError[] {new AnalysisError ( |
120 null, | 131 null, |
121 HtmlWarningCode.INVALID_URI, | 132 HtmlWarningCode.INVALID_URI, |
122 "-")}); | 133 "-")}); |
123 } | 134 } |
124 | 135 |
125 private HtmlEntryImpl entryWithValidState() { | 136 private HtmlEntryImpl entryWithValidState() { |
126 HtmlEntryImpl entry = new HtmlEntryImpl(); | 137 HtmlEntryImpl entry = new HtmlEntryImpl(); |
127 entry.setValue(HtmlEntry.ELEMENT, null); | 138 entry.setValue(HtmlEntry.ELEMENT, null); |
128 entry.setValue(HtmlEntry.HINTS, null); | 139 entry.setValue(HtmlEntry.HINTS, null); |
danrubel
2013/11/25 02:26:12
entry.setValue(HtmlEntry.PARSE_ERRORS, null);
Brian Wilkerson
2013/11/25 19:04:36
Done
| |
129 entry.setValue(SourceEntry.LINE_INFO, null); | 140 entry.setValue(SourceEntry.LINE_INFO, null); |
130 entry.setValue(HtmlEntry.PARSED_UNIT, null); | 141 entry.setValue(HtmlEntry.PARSED_UNIT, null); |
131 entry.setValue(HtmlEntry.REFERENCED_LIBRARIES, null); | 142 entry.setValue(HtmlEntry.REFERENCED_LIBRARIES, null); |
132 entry.setValue(HtmlEntry.RESOLUTION_ERRORS, null); | 143 entry.setValue(HtmlEntry.RESOLUTION_ERRORS, null); |
133 | 144 |
134 assertSame(CacheState.VALID, entry.getState(HtmlEntry.ELEMENT)); | 145 assertSame(CacheState.VALID, entry.getState(HtmlEntry.ELEMENT)); |
135 assertSame(CacheState.VALID, entry.getState(HtmlEntry.HINTS)); | 146 assertSame(CacheState.VALID, entry.getState(HtmlEntry.HINTS)); |
136 assertSame(CacheState.VALID, entry.getState(SourceEntry.LINE_INFO)); | 147 assertSame(CacheState.VALID, entry.getState(SourceEntry.LINE_INFO)); |
danrubel
2013/11/25 02:26:12
assertSame(CacheState.VALID, entry.getState(HtmlEn
Brian Wilkerson
2013/11/25 19:04:36
Done
| |
137 assertSame(CacheState.VALID, entry.getState(HtmlEntry.PARSED_UNIT)); | 148 assertSame(CacheState.VALID, entry.getState(HtmlEntry.PARSED_UNIT)); |
138 assertSame(CacheState.VALID, entry.getState(HtmlEntry.REFERENCED_LIBRARIES)) ; | 149 assertSame(CacheState.VALID, entry.getState(HtmlEntry.REFERENCED_LIBRARIES)) ; |
139 assertSame(CacheState.VALID, entry.getState(HtmlEntry.RESOLUTION_ERRORS)); | 150 assertSame(CacheState.VALID, entry.getState(HtmlEntry.RESOLUTION_ERRORS)); |
140 return entry; | 151 return entry; |
141 } | 152 } |
142 | 153 |
143 private void setState(DataDescriptor<?> descriptor) { | 154 private void setState(DataDescriptor<?> descriptor) { |
144 HtmlEntryImpl entry = new HtmlEntryImpl(); | 155 HtmlEntryImpl entry = new HtmlEntryImpl(); |
145 assertNotSame(CacheState.FLUSHED, entry.getState(descriptor)); | 156 assertNotSame(CacheState.FLUSHED, entry.getState(descriptor)); |
146 entry.setState(descriptor, CacheState.FLUSHED); | 157 entry.setState(descriptor, CacheState.FLUSHED); |
147 assertSame(CacheState.FLUSHED, entry.getState(descriptor)); | 158 assertSame(CacheState.FLUSHED, entry.getState(descriptor)); |
148 } | 159 } |
149 | 160 |
150 private <E> void setValue(DataDescriptor<E> descriptor, E newValue) { | 161 private <E> void setValue(DataDescriptor<E> descriptor, E newValue) { |
151 HtmlEntryImpl entry = new HtmlEntryImpl(); | 162 HtmlEntryImpl entry = new HtmlEntryImpl(); |
152 E value = entry.getValue(descriptor); | 163 E value = entry.getValue(descriptor); |
153 assertNotSame(value, newValue); | 164 assertNotSame(value, newValue); |
154 entry.setValue(descriptor, newValue); | 165 entry.setValue(descriptor, newValue); |
155 assertSame(CacheState.VALID, entry.getState(descriptor)); | 166 assertSame(CacheState.VALID, entry.getState(descriptor)); |
156 assertSame(newValue, entry.getValue(descriptor)); | 167 assertSame(newValue, entry.getValue(descriptor)); |
157 } | 168 } |
158 } | 169 } |
OLD | NEW |