Removed MapOverlay.

This commit is contained in:
Dennis Guse
2019-06-25 05:52:47 +02:00
parent 8255fef72d
commit 5a264c5c53
13 changed files with 0 additions and 1250 deletions
@@ -1,104 +0,0 @@
/*
* Copyright 2012 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.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.test.AndroidTestCase;
/**
* Tests for the {@link DynamicSpeedTrackPathDescriptor}.
*
* @author Youtao Liu
*/
public class DynamicSpeedTrackPathDescriptorTest extends AndroidTestCase {
private Context context;
@Override
protected void setUp() throws Exception {
super.setUp();
context = getContext();
}
/**
* Tests the method {@link DynamicSpeedTrackPathDescriptor#getSpeedMargin()}
* with zero, normal and illegal value.
*/
public void testGetSpeedMargin() {
// The default value of speedMargin is 25.
int[] expectations = { 0, 50, 99, 25 };
// Test
for (int i = 0; i < expectations.length; i++) {
PreferencesUtils.setInt(context, R.string.track_color_mode_percentage_key, expectations[i]);
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
context);
assertEquals(expectations[i], dynamicSpeedTrackPathDescriptor.getSpeedMargin());
}
}
/**
* Tests {@link DynamicSpeedTrackPathDescriptor#getSlowSpeed()}.
*/
public void testGetSlowSpeed() {
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
context);
dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(50);
dynamicSpeedTrackPathDescriptor.setSpeedMargin(10);
assertEquals(50.0, dynamicSpeedTrackPathDescriptor.getAverageMovingSpeed());
assertEquals(45.0, dynamicSpeedTrackPathDescriptor.getSlowSpeed());
}
/**
* Tests {@link DynamicSpeedTrackPathDescriptor#getNormalSpeed()}.
*/
public void testGetNormalSpeed() {
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
context);
dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(50);
dynamicSpeedTrackPathDescriptor.setSpeedMargin(10);
assertEquals(50.0, dynamicSpeedTrackPathDescriptor.getAverageMovingSpeed());
assertEquals(55.0, dynamicSpeedTrackPathDescriptor.getNormalSpeed());
}
/**
* Tests {@link DynamicSpeedTrackPathDescriptor#updateState(com.google.android.apps.mytracks.stats.TripStatistics)}
* by different averageMovingSpeed.
*/
public void testIsDiffereceSignificant() {
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
context);
double[] averageMovingSpeeds = { 0, 30, 30, 30 };
double[] newAverageMovingSpeed = { 20, 30,
// Difference is less than CRITICAL_DIFFERENCE_PERCENTAGE
30 * (1 + (DynamicSpeedTrackPathDescriptor.CRITICAL_DIFFERENCE_PERCENTAGE / 100) / 2),
// Difference is more than CRITICAL_DIFFERENCE_PERCENTAGE
30 * (1 + (DynamicSpeedTrackPathDescriptor.CRITICAL_DIFFERENCE_PERCENTAGE / 100.00) * 2) };
boolean[] expectedValues = { true, false, false, true };
double[] expectedAverageMovingSpeed = { 0, 30, 30, 30 };
// Test
for (int i = 0; i < newAverageMovingSpeed.length; i++) {
dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(averageMovingSpeeds[i]);
assertEquals(expectedValues[i], dynamicSpeedTrackPathDescriptor.isDifferenceSignificant(
averageMovingSpeeds[i], newAverageMovingSpeed[i]));
assertEquals(expectedAverageMovingSpeed[i],
dynamicSpeedTrackPathDescriptor.getAverageMovingSpeed());
}
}
}
@@ -1,92 +0,0 @@
/*
* Copyright 2012 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.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.test.AndroidTestCase;
/**
* Tests for the {@link FixedSpeedTrackPathDescriptor}.
*
* @author Youtao Liu
*/
public class FixedSpeedTrackPathDescriptorTest extends AndroidTestCase {
@Override
protected void tearDown() throws Exception {
Context context = getContext();
PreferencesUtils.setString(
context, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT);
PreferencesUtils.setInt(context, R.string.track_color_mode_slow_key,
PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT);
PreferencesUtils.setInt(context, R.string.track_color_mode_medium_key,
PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT);
super.tearDown();
}
/**
* Tests when the slow speed and the normal speed are both zero.
*/
public void testGetSpeed_zero() {
testSpeed(0, 0);
}
/**
* Tests when the slow speed and the normal speed are both one.
*/
public void testGetSpeed_one() {
testSpeed(1, 1);
}
/**
* Tests when the slow speed and the normal speed are both large number. E.g.,
* 99 and 100.
*/
public void testGetSpeed_large() {
testSpeed(99, 100);
}
/**
* Tests when the slow speed and the normal speed are both the default value.
*/
public void testGetSpeed_default() {
testSpeed(PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT,
PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT);
}
private void testSpeed(int slowSpeed, int normalSpeed) {
testSpeed(slowSpeed, normalSpeed, true);
testSpeed(slowSpeed, normalSpeed, false);
}
private void testSpeed(int slowSpeed, int normalSpeed, boolean metric) {
Context context = getContext();
PreferencesUtils.setString(context, R.string.stats_units_key,
context.getString(metric ? R.string.stats_units_metric : R.string.stats_units_imperial));
PreferencesUtils.setInt(context, R.string.track_color_mode_slow_key, slowSpeed);
PreferencesUtils.setInt(context, R.string.track_color_mode_medium_key, normalSpeed);
FixedSpeedTrackPathDescriptor fixedSpeedTrackPathDescriptor = new FixedSpeedTrackPathDescriptor(
context);
double expectedSlowSpeed = metric ? slowSpeed : slowSpeed * UnitConversions.MI_TO_KM;
double expectedNormalSpeed = metric ? normalSpeed : normalSpeed * UnitConversions.MI_TO_KM;
assertEquals(expectedSlowSpeed, fixedSpeedTrackPathDescriptor.getSlowSpeed());
assertEquals(expectedNormalSpeed, fixedSpeedTrackPathDescriptor.getNormalSpeed());
}
}
@@ -1,60 +0,0 @@
/*
* Copyright 2012 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 android.content.Context;
import android.test.AndroidTestCase;
/**
* Tests for the {@link MultiColorTrackPath}.
*
* @author Youtao Liu
*/
public class MultiColorTrackPathTest extends AndroidTestCase {
private MultiColorTrackPath multiColorTrackPath;
private Context context;
@Override
protected void setUp() throws Exception {
super.setUp();
context = getContext();
}
/**
* Tests the {@link MultiColorTrackPath#getColor(double)} when use dynamic speed
* track path descriptor.
*/
public void testGetColor_DynamicSpeedTrackPathDescriptor() {
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
context);
dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(50);
dynamicSpeedTrackPathDescriptor.setSpeedMargin(10);
multiColorTrackPath = new MultiColorTrackPath(context, dynamicSpeedTrackPathDescriptor);
// Slow speed should be below 45 (10% of 50), and fast speed should be above
// 55 (10% of 50).
assertEquals(multiColorTrackPath.getSlowColor(), multiColorTrackPath.getColor(5));
assertEquals(multiColorTrackPath.getSlowColor(), multiColorTrackPath.getColor(44));
assertEquals(multiColorTrackPath.getNormalColor(), multiColorTrackPath.getColor(50));
assertEquals(multiColorTrackPath.getNormalColor(), multiColorTrackPath.getColor(54));
assertEquals(multiColorTrackPath.getFastColor(), multiColorTrackPath.getColor(56));
assertEquals(multiColorTrackPath.getFastColor(), multiColorTrackPath.getColor(100));
assertNotSame(multiColorTrackPath.getSlowColor(), multiColorTrackPath.getNormalColor());
assertNotSame(multiColorTrackPath.getSlowColor(), multiColorTrackPath.getFastColor());
}
}