diff --git a/MyTracks/src/com/google/android/apps/mytracks/maps/FixedSpeedTrackPathDescriptor.java b/MyTracks/src/com/google/android/apps/mytracks/maps/FixedSpeedTrackPathDescriptor.java index d00ed9e0b..e69b4a6a5 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/maps/FixedSpeedTrackPathDescriptor.java +++ b/MyTracks/src/com/google/android/apps/mytracks/maps/FixedSpeedTrackPathDescriptor.java @@ -96,13 +96,13 @@ public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSha try { 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) { slowSpeed = 9; } try { 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) { normalSpeed = 17; } diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorDynamicSpeedTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorDynamicSpeedTest.java index 07fbbba03..63eec1182 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorDynamicSpeedTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorDynamicSpeedTest.java @@ -15,6 +15,8 @@ */ package com.google.android.apps.mytracks.maps; +import com.google.android.apps.mytracks.MockPath; + import android.location.Location; /** @@ -39,9 +41,13 @@ public class TrackPathDescriptorDynamicSpeedTest extends TrackPathPainterTestCas int startLocationIdx = 0; Boolean alwaysVisible = true; + assertNotNull(painter); painter.updatePath(myTracksOverlay.getMapProjection(mockView), myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible, myTracksOverlay.getPoints()); + assertNotNull(myTracksOverlay.getLastPath()); + assertTrue(myTracksOverlay.getLastPath() instanceof MockPath); painter.drawTrack(canvas); + } } diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorFixedSpeedTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorFixedSpeedTest.java index 4a46efd98..d78c02fcb 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorFixedSpeedTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorFixedSpeedTest.java @@ -15,6 +15,8 @@ */ package com.google.android.apps.mytracks.maps; +import com.google.android.apps.mytracks.MockPath; + import android.location.Location; /** @@ -39,9 +41,12 @@ public class TrackPathDescriptorFixedSpeedTest extends TrackPathPainterTestCase int startLocationIdx = 0; Boolean alwaysVisible = true; + assertNotNull(painter); painter.updatePath(myTracksOverlay.getMapProjection(mockView), myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible, myTracksOverlay.getPoints()); + assertNotNull(myTracksOverlay.getLastPath()); + assertTrue(myTracksOverlay.getLastPath() instanceof MockPath); painter.drawTrack(canvas); } } diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorsTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorsTest.java deleted file mode 100644 index 880f1bd64..000000000 --- a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathDescriptorsTest.java +++ /dev/null @@ -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); - } -} diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathPainterFactoryTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathPainterFactoryTest.java index 4e3d64280..52d53233a 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathPainterFactoryTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathPainterFactoryTest.java @@ -15,7 +15,10 @@ */ 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.MockPath; import com.google.android.maps.mytracks.R; import android.content.Context; @@ -46,12 +49,16 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase { return; } - testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_none); - testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_fixed); - testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_dynamic); + testTrackPathPainterFactorySpecific(context, prefs, R.string.track_color_mode_none, + SingleColorTrackPathPainter.class); + 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), context.getString(R.string.track_color_mode_key)).commit(); @@ -60,9 +67,13 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase { 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), myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible, myTracksOverlay.getPoints()); + assertNotNull(myTracksOverlay.getLastPath()); + assertTrue(myTracksOverlay.getLastPath() instanceof MockPath); painter.drawTrack(canvas); } } diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathPainterSingleColorTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathPainterSingleColorTest.java index b7bdf04af..6c6682e32 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathPainterSingleColorTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/maps/TrackPathPainterSingleColorTest.java @@ -15,6 +15,8 @@ */ package com.google.android.apps.mytracks.maps; +import com.google.android.apps.mytracks.MockPath; + import android.location.Location; /** @@ -39,9 +41,12 @@ public class TrackPathPainterSingleColorTest extends TrackPathPainterTestCase { int startLocationIdx = 0; Boolean alwaysVisible = true; + assertNotNull(painter); painter.updatePath(myTracksOverlay.getMapProjection(mockView), myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible, myTracksOverlay.getPoints()); + assertNotNull(myTracksOverlay.getLastPath()); + assertTrue(myTracksOverlay.getLastPath() instanceof MockPath); painter.drawTrack(canvas); } }