Changeset 10867 in josm for trunk/test/unit/org
- Timestamp:
- 2016-08-21T15:38:50+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java
r10856 r10867 17 17 import org.openstreetmap.josm.data.coor.LatLon; 18 18 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint; 19 import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle; 19 20 20 21 /** … … 151 152 152 153 /** 154 * Test {@link MapViewState#OUTSIDE_BOTTOM} and similar constants. 155 */ 156 @Test 157 public void testOutsideFlags() { 158 assertEquals(1, Integer.bitCount(MapViewState.OUTSIDE_BOTTOM)); 159 assertEquals(1, Integer.bitCount(MapViewState.OUTSIDE_TOP)); 160 assertEquals(1, Integer.bitCount(MapViewState.OUTSIDE_LEFT)); 161 assertEquals(1, Integer.bitCount(MapViewState.OUTSIDE_RIGHT)); 162 assertEquals(4, Integer.bitCount(MapViewState.OUTSIDE_BOTTOM | MapViewState.OUTSIDE_TOP 163 | MapViewState.OUTSIDE_LEFT | MapViewState.OUTSIDE_RIGHT)); 164 } 165 166 /** 167 * Test {@link MapViewPoint#getOutsideRectangleFlags(MapViewRectangle)} 168 */ 169 @Test 170 public void testPointGetOutsideRectangleFlags() { 171 MapViewRectangle rect = state.getForView(0, 0).rectTo(state.getForView(10, 10)); 172 assertEquals(0, state.getForView(1, 1).getOutsideRectangleFlags(rect)); 173 assertEquals(0, state.getForView(1, 5).getOutsideRectangleFlags(rect)); 174 assertEquals(0, state.getForView(9, 1).getOutsideRectangleFlags(rect)); 175 assertEquals(0, state.getForView(10 - 1e-10, 1e-10).getOutsideRectangleFlags(rect)); 176 assertEquals(0, state.getForView(10 - 1e-10, 10 - 1e-10).getOutsideRectangleFlags(rect)); 177 178 179 assertEquals(MapViewState.OUTSIDE_TOP, state.getForView(1, -11).getOutsideRectangleFlags(rect)); 180 assertEquals(MapViewState.OUTSIDE_TOP, state.getForView(1, -1e20).getOutsideRectangleFlags(rect)); 181 182 assertEquals(MapViewState.OUTSIDE_BOTTOM, state.getForView(1, 11).getOutsideRectangleFlags(rect)); 183 assertEquals(MapViewState.OUTSIDE_BOTTOM, state.getForView(1, 1e20).getOutsideRectangleFlags(rect)); 184 185 assertEquals(MapViewState.OUTSIDE_LEFT, state.getForView(-11, 1).getOutsideRectangleFlags(rect)); 186 assertEquals(MapViewState.OUTSIDE_LEFT, state.getForView(-1e20, 1).getOutsideRectangleFlags(rect)); 187 assertEquals(MapViewState.OUTSIDE_RIGHT, state.getForView(11, 1).getOutsideRectangleFlags(rect)); 188 assertEquals(MapViewState.OUTSIDE_RIGHT, state.getForView(1e20, 1).getOutsideRectangleFlags(rect)); 189 190 assertEquals(MapViewState.OUTSIDE_RIGHT | MapViewState.OUTSIDE_TOP, state.getForView(11, -11).getOutsideRectangleFlags(rect)); 191 assertEquals(MapViewState.OUTSIDE_RIGHT | MapViewState.OUTSIDE_BOTTOM, state.getForView(11, 11).getOutsideRectangleFlags(rect)); 192 assertEquals(MapViewState.OUTSIDE_LEFT | MapViewState.OUTSIDE_TOP, state.getForView(-11, -11).getOutsideRectangleFlags(rect)); 193 assertEquals(MapViewState.OUTSIDE_LEFT | MapViewState.OUTSIDE_BOTTOM, state.getForView(-11, 11).getOutsideRectangleFlags(rect)); 194 } 195 196 /** 197 * Test {@link MapViewPoint#oneNormInView(MapViewPoint)} 198 */ 199 @Test 200 public void testPointOneNormInView() { 201 MapViewPoint p = state.getForView(5, 15); 202 assertEquals(0, p.oneNormInView(p), 1e-10); 203 assertEquals(6, p.oneNormInView(state.getForView(-1, 15)), 1e-10); 204 assertEquals(5, p.oneNormInView(state.getForView(5, 20)), 1e-10); 205 assertEquals(22, p.oneNormInView(state.getForView(-1, -1)), 1e-10); 206 assertEquals(40, p.oneNormInView(state.getForView(30, 30)), 1e-10); 207 } 208 209 /** 153 210 * Test {@link MapViewState.MapViewViewPoint#toString()} and {@link MapViewState.MapViewEastNorthPoint#toString()} 154 211 */
Note:
See TracChangeset
for help on using the changeset viewer.