From fd0ce6c1cf062c502fc666f3fa824cf72b4d0696 Mon Sep 17 00:00:00 2001 From: Forrest Guice Date: Mon, 7 Feb 2022 13:19:48 -0700 Subject: [PATCH] test --- .../suntimeswidget/SuntimesResTest.java | 19 ++++++++++++++++-- .../suntimeswidget/map/MapProjectionTest.java | 1 + .../settings/AppSettingsTest.java | 20 ++++++++++++++++++- .../settings/WidgetSettingsTest.java | 4 ++-- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/src/androidTest/java/com/forrestguice/suntimeswidget/SuntimesResTest.java b/app/src/androidTest/java/com/forrestguice/suntimeswidget/SuntimesResTest.java index a785ce9c1..7465bc905 100644 --- a/app/src/androidTest/java/com/forrestguice/suntimeswidget/SuntimesResTest.java +++ b/app/src/androidTest/java/com/forrestguice/suntimeswidget/SuntimesResTest.java @@ -1,5 +1,5 @@ /** - Copyright (C) 2018-2019 Forrest Guice + Copyright (C) 2018-2022 Forrest Guice This file is part of SuntimesWidget. SuntimesWidget is free software: you can redistribute it and/or modify @@ -57,6 +57,7 @@ public void test_stringArrays() verify_stringArrayLength("locale_credits", R.array.locale_credits, "locale_display", R.array.locale_display); verify_stringArrayLength("appThemes_values", R.array.appThemes_values, "appThemes_display", R.array.appThemes_display); + verify_stringArrayValuesOfEnum("localeMode_values", R.array.localeMode_values, AppSettings.LocaleMode.class); verify_stringArrayLength("localeMode_values", R.array.localeMode_values, "localeMode_display", R.array.localeMode_display); verify_stringArrayLength("localeMode_display", R.array.localeMode_display, "LocaleMode (ENUM)", AppSettings.LocaleMode.values()); @@ -70,6 +71,7 @@ public void test_stringArrays() verify_stringArrayLength("directions_short", R.array.directions_short, "directions_long", R.array.directions_long); verify_stringArrayLength("directions_short", R.array.directions_short, "CardinalDirection (ENUM)", SuntimesUtils.CardinalDirection.values()); + verify_stringArrayValuesOfEnum("timezoneSort_values", R.array.timezoneSort_values, WidgetTimezones.TimeZoneSort.class); verify_stringArrayLength("timezoneSort_values", R.array.timezoneSort_values, "timezoneSort_display", R.array.timezoneSort_display); verify_stringArrayLength("timezoneSort_display", R.array.timezoneSort_display, "TimeZoneSort (ENUM)", WidgetTimezones.TimeZoneSort.values()); @@ -79,18 +81,31 @@ public void test_stringArrays() verify_stringArrayLength("dateTapActions_values", R.array.dateTapActions_values, "dateTapActions_display", R.array.dateTapActions_display); verify_enumTapActions("dateTapActions_values", R.array.dateTapActions_values); + verify_stringArrayValuesOfEnum("timeFormatMode_values", R.array.timeFormatMode_values, WidgetSettings.TimeFormatMode.class); verify_stringArrayLength("timeFormatMode_values", R.array.timeFormatMode_values, "timeFormatMode_display", R.array.timeFormatMode_display); - verify_stringArrayLength("timeFormatMode_display", R.array.timeFormatMode_display, "TimeFormatMode (ENUM)", WidgetSettings.TimeFormatMode.values()); + verify_stringArrayValuesOfEnum("lengthUnits_values", R.array.lengthUnits_values, WidgetSettings.LengthUnit.class); verify_stringArrayLength("lengthUnits_values", R.array.lengthUnits_values, "lengthUnits_display", R.array.lengthUnits_display); + verify_stringArrayLength("alarm_hardwarebutton_actions_values", R.array.alarm_hardwarebutton_actions_values, "alarm_hardwarebutton_actions_display", R.array.alarm_hardwarebutton_actions_display); verify_stringArrayLength("getFix_maxAge_values", R.array.getFix_maxAge_values, "getFix_maxAge_display", R.array.getFix_maxAge_display); verify_stringArrayLength("getFix_maxElapse_values", R.array.getFix_maxElapse_values, "getFix_maxElapse_display", R.array.getFix_maxElapse_display); verify_stringArrayLength("noteTapActions_values", R.array.noteTapActions_values, "noteTapActions_display", R.array.noteTapActions_display); + + verify_stringArrayValuesOfEnum("solsticeTrackingMode_values", R.array.solsticeTrackingMode_values, WidgetSettings.TrackingMode.class); verify_stringArrayLength("solsticeTrackingMode_values", R.array.solsticeTrackingMode_values, "solsticeTrackingMode_display", R.array.solsticeTrackingMode_display); } } + public void verify_stringArrayValuesOfEnum(String tag1, int array1Id, Class enumClass) + { + Context context = activityRule.getActivity(); + String[] values = context.getResources().getStringArray(array1Id); + for (String value : values) { + Enum e = Enum.valueOf(enumClass, value); + } + } + public void verify_enumTapActions(String tag1, int array1Id) { Context context = activityRule.getActivity(); diff --git a/app/src/androidTest/java/com/forrestguice/suntimeswidget/map/MapProjectionTest.java b/app/src/androidTest/java/com/forrestguice/suntimeswidget/map/MapProjectionTest.java index 1b71a9f84..20b8eac42 100644 --- a/app/src/androidTest/java/com/forrestguice/suntimeswidget/map/MapProjectionTest.java +++ b/app/src/androidTest/java/com/forrestguice/suntimeswidget/map/MapProjectionTest.java @@ -129,6 +129,7 @@ protected void test_WorldMapEquiazimuthal2_points(double[] center, double R, dou WorldMapEquiazimuthal2 projection = new WorldMapEquiazimuthal2(); projection.center = options.center; + projection.initMatrix(); double[] point, coords; for (int i=0; i