forked from upstream-mirrors/OpenTracks
Review issues corrected, pending issue about "expect" with class type argument
This commit is contained in:
+2
-2
@@ -96,13 +96,13 @@ public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSha
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||||
R.string.track_color_mode_fixed_speed_slow_key), "9"));
|
R.string.track_color_mode_fixed_speed_slow_key), "9"));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
slowSpeed = 9;
|
slowSpeed = 9;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
normalSpeed = Integer.parseInt(prefs.getString(context.getString(
|
normalSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||||
R.string.track_color_mode_fixed_speed_medium_key), "17"));
|
R.string.track_color_mode_fixed_speed_medium_key), "17"));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
normalSpeed = 17;
|
normalSpeed = 17;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.MockPath;
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,9 +41,13 @@ public class TrackPathDescriptorDynamicSpeedTest extends TrackPathPainterTestCas
|
|||||||
int startLocationIdx = 0;
|
int startLocationIdx = 0;
|
||||||
Boolean alwaysVisible = true;
|
Boolean alwaysVisible = true;
|
||||||
|
|
||||||
|
assertNotNull(painter);
|
||||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||||
myTracksOverlay.getPoints());
|
myTracksOverlay.getPoints());
|
||||||
|
assertNotNull(myTracksOverlay.getLastPath());
|
||||||
|
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
|
||||||
painter.drawTrack(canvas);
|
painter.drawTrack(canvas);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.MockPath;
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,9 +41,12 @@ public class TrackPathDescriptorFixedSpeedTest extends TrackPathPainterTestCase
|
|||||||
int startLocationIdx = 0;
|
int startLocationIdx = 0;
|
||||||
Boolean alwaysVisible = true;
|
Boolean alwaysVisible = true;
|
||||||
|
|
||||||
|
assertNotNull(painter);
|
||||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||||
myTracksOverlay.getPoints());
|
myTracksOverlay.getPoints());
|
||||||
|
assertNotNull(myTracksOverlay.getLastPath());
|
||||||
|
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
|
||||||
painter.drawTrack(canvas);
|
painter.drawTrack(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations under
|
|
||||||
* the License.
|
|
||||||
*/
|
|
||||||
package com.google.android.apps.mytracks.maps;
|
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.MockMyTracksOverlay;
|
|
||||||
import com.google.android.maps.MapView;
|
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.location.Location;
|
|
||||||
import android.test.AndroidTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for the MyTracks map overlay.
|
|
||||||
*
|
|
||||||
* @author Bartlomiej Niechwiej
|
|
||||||
* @author Vangelis S.
|
|
||||||
*/
|
|
||||||
public class TrackPathDescriptorsTest extends AndroidTestCase {
|
|
||||||
private Canvas canvas;
|
|
||||||
private MockMyTracksOverlay myTracksOverlay;
|
|
||||||
private MapView mockView;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
canvas = new Canvas();
|
|
||||||
myTracksOverlay = new MockMyTracksOverlay(getContext());
|
|
||||||
// Enable drawing.
|
|
||||||
myTracksOverlay.setTrackDrawingEnabled(true);
|
|
||||||
mockView = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSimpeColorTrackPathPainter() throws Exception {
|
|
||||||
Location location = new Location("gps");
|
|
||||||
location.setLatitude(10);
|
|
||||||
|
|
||||||
for (int i = 0; i < 100; ++i) {
|
|
||||||
location = new Location("gps");
|
|
||||||
location.setLatitude(20 + i / 2);
|
|
||||||
location.setLongitude(150 - i);
|
|
||||||
myTracksOverlay.addLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackPathPainter painter = new SingleColorTrackPathPainter(getContext());
|
|
||||||
int startLocationIdx = 0;
|
|
||||||
Boolean alwaysVisible = true;
|
|
||||||
|
|
||||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
|
||||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
|
||||||
myTracksOverlay.getPoints());
|
|
||||||
painter.drawTrack(canvas);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFixedSpeedTrackPathDescriptor() throws Exception {
|
|
||||||
Location location = new Location("gps");
|
|
||||||
location.setLatitude(10);
|
|
||||||
|
|
||||||
for (int i = 0; i < 100; ++i) {
|
|
||||||
location = new Location("gps");
|
|
||||||
location.setLatitude(20 + i / 2);
|
|
||||||
location.setLongitude(150 - i);
|
|
||||||
myTracksOverlay.addLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackPathPainter painter = new DynamicSpeedTrackPathPainter(getContext(), new FixedSpeedTrackPathDescriptor(getContext()));
|
|
||||||
int startLocationIdx = 0;
|
|
||||||
Boolean alwaysVisible = true;
|
|
||||||
|
|
||||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
|
||||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
|
||||||
myTracksOverlay.getPoints());
|
|
||||||
painter.drawTrack(canvas);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDynamicSpeedTrackPathDescriptor() throws Exception {
|
|
||||||
Location location = new Location("gps");
|
|
||||||
location.setLatitude(10);
|
|
||||||
|
|
||||||
for (int i = 0; i < 100; ++i) {
|
|
||||||
location = new Location("gps");
|
|
||||||
location.setLatitude(20 + i / 2);
|
|
||||||
location.setLongitude(150 - i);
|
|
||||||
myTracksOverlay.addLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackPathPainter painter = new DynamicSpeedTrackPathPainter(getContext(), new DynamicSpeedTrackPathDescriptor(getContext()));
|
|
||||||
int startLocationIdx = 0;
|
|
||||||
Boolean alwaysVisible = true;
|
|
||||||
|
|
||||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
|
||||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
|
||||||
myTracksOverlay.getPoints());
|
|
||||||
painter.drawTrack(canvas);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+15
-4
@@ -15,7 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
|
import static com.google.android.testing.mocking.AndroidMock.expect;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
|
import com.google.android.apps.mytracks.MockPath;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -46,12 +49,16 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_none);
|
testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_none,
|
||||||
testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_fixed);
|
SingleColorTrackPathPainter.class);
|
||||||
testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_dynamic);
|
testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_fixed,
|
||||||
|
DynamicSpeedTrackPathPainter.class);
|
||||||
|
testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_dynamic,
|
||||||
|
DynamicSpeedTrackPathPainter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testTrackPathPainterFactorySpecific(Context context, SharedPreferences prefs, int track_color_mode) {
|
private void testTrackPathPainterFactorySpecific(Context context, SharedPreferences prefs,
|
||||||
|
int track_color_mode, Object classtested) {
|
||||||
prefs.edit().putString(context.getString(track_color_mode),
|
prefs.edit().putString(context.getString(track_color_mode),
|
||||||
context.getString(R.string.track_color_mode_key)).commit();
|
context.getString(R.string.track_color_mode_key)).commit();
|
||||||
|
|
||||||
@@ -60,9 +67,13 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase {
|
|||||||
|
|
||||||
TrackPathPainter painter = TrackPathPainterFactory.getTrackPathPainter(context);
|
TrackPathPainter painter = TrackPathPainterFactory.getTrackPathPainter(context);
|
||||||
|
|
||||||
|
assertNotNull(painter);
|
||||||
|
expect(painter instanceof classtested.getClass()); //i cant find the way to make this part work... :S
|
||||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||||
myTracksOverlay.getPoints());
|
myTracksOverlay.getPoints());
|
||||||
|
assertNotNull(myTracksOverlay.getLastPath());
|
||||||
|
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
|
||||||
painter.drawTrack(canvas);
|
painter.drawTrack(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.MockPath;
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,9 +41,12 @@ public class TrackPathPainterSingleColorTest extends TrackPathPainterTestCase {
|
|||||||
int startLocationIdx = 0;
|
int startLocationIdx = 0;
|
||||||
Boolean alwaysVisible = true;
|
Boolean alwaysVisible = true;
|
||||||
|
|
||||||
|
assertNotNull(painter);
|
||||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||||
myTracksOverlay.getPoints());
|
myTracksOverlay.getPoints());
|
||||||
|
assertNotNull(myTracksOverlay.getLastPath());
|
||||||
|
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
|
||||||
painter.drawTrack(canvas);
|
painter.drawTrack(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user