Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestguice committed Feb 7, 2022
1 parent 4e60654 commit fd0ce6c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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());

Expand All @@ -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());

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<testCoords.length; i++)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
Copyright (C) 2017-2019 Forrest Guice
Copyright (C) 2017-2022 Forrest Guice
This file is part of SuntimesWidget.
SuntimesWidget is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -129,6 +129,24 @@ public void test_showEquinoxPref()
boolean value = AppSettings.loadShowEquinoxPref(context);
}

@Test
public void test_showHeaderIcon()
{
boolean defaultValue0 = AppSettings.PREF_DEF_UI_SHOWHEADER_ICON;
boolean defaultValue1 = Boolean.valueOf(context.getResources().getString(R.string.def_app_ui_showheader_icon));
assertTrue("defaults should match", defaultValue0 == defaultValue1);
boolean value = AppSettings.loadShowHeaderIconPref(context);
}

@Test
public void test_showHeaderText()
{
int defaultValue0 = AppSettings.PREF_DEF_UI_SHOWHEADER_TEXT;
int defaultValue1 = Integer.parseInt(context.getResources().getString(R.string.def_app_ui_showheader_text));
assertTrue("defaults should match", defaultValue0 == defaultValue1);
int value = AppSettings.loadShowHeaderTextPref(context);
}

@Test
public void test_showDataSourcePref()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
Copyright (C) 2017-2021 Forrest Guice
Copyright (C) 2017-2022 Forrest Guice
This file is part of SuntimesWidget.
SuntimesWidget is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -620,7 +620,7 @@ public void test_allowResizePref()

WidgetSettings.deleteAllowResizePref(context, appWidgetId);
boolean pref0 = WidgetSettings.loadAllowResizePref(context, appWidgetId);
assertTrue("mode should be default (true) but was " + pref0, pref0 && pref0 == WidgetSettings.PREF_DEF_APPEARANCE_ALLOWRESIZE);
assertTrue("mode should be default (true) but was " + pref0, !pref0 && pref0 == WidgetSettings.PREF_DEF_APPEARANCE_ALLOWRESIZE);
}

@Test
Expand Down

0 comments on commit fd0ce6c

Please sign in to comment.