Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 97 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.13.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -161,6 +169,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.3"
fake_async:
dependency: transitive
description:
name: fake_async
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.dev"
source: hosted
version: "1.3.3"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -310,6 +326,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.2.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
flutter_web_auth_2:
dependency: "direct main"
description:
Expand Down Expand Up @@ -443,6 +464,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.9.1"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.dev"
source: hosted
version: "11.0.2"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev"
source: hosted
version: "3.0.10"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
linkify:
dependency: transitive
description:
Expand All @@ -467,6 +512,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.6.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev"
source: hosted
version: "0.12.17"
material_color_utilities:
dependency: transitive
description:
Expand All @@ -479,10 +532,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev"
source: hosted
version: "1.16.0"
version: "1.17.0"
mgrs_dart:
dependency: transitive
description:
Expand All @@ -491,6 +544,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
mocktail:
dependency: "direct dev"
description:
name: mocktail
sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
nested:
dependency: transitive
description:
Expand Down Expand Up @@ -760,6 +821,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
url: "https://pub.dev"
source: hosted
version: "1.12.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
string_scanner:
dependency: transitive
description:
Expand All @@ -784,6 +861,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.2"
test_api:
dependency: transitive
description:
name: test_api
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev"
source: hosted
version: "0.7.7"
timezone:
dependency: transitive
description:
Expand Down Expand Up @@ -916,10 +1001,18 @@ packages:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.2.0"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
url: "https://pub.dev"
source: hosted
version: "15.0.2"
web:
dependency: transitive
description:
Expand Down
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ dependencies:
csv: ^6.0.0

dev_dependencies:
flutter_test:
sdk: flutter
mocktail: ^1.0.4
flutter_launcher_icons: ^0.14.4
flutter_native_splash: ^2.4.6

Expand Down
13 changes: 10 additions & 3 deletions test/models/tile_provider_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:flock_map_app/models/tile_provider.dart';
import 'package:deflockapp/models/tile_provider.dart';

void main() {
group('TileType', () {
Expand Down Expand Up @@ -127,10 +127,17 @@ void main() {
expect(satelliteType.attribution, '© Microsoft Corporation');
});

test('all default providers are usable', () {
test('providers without API key requirements are usable', () {
final providers = DefaultTileProviders.createDefaults();
for (final provider in providers) {
expect(provider.isUsable, isTrue, reason: '${provider.name} should be usable');
final needsKey = provider.tileTypes.any((t) => t.requiresApiKey);
if (needsKey) {
expect(provider.isUsable, isFalse,
reason: '${provider.name} requires API key and has none set');
} else {
expect(provider.isUsable, isTrue,
reason: '${provider.name} should be usable without API key');
}
}
});
});
Expand Down
57 changes: 36 additions & 21 deletions test/services/deflock_tile_provider_test.dart
Original file line number Diff line number Diff line change
@@ -1,40 +1,55 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:mocktail/mocktail.dart';
Comment thread
dougborg marked this conversation as resolved.

import '../../lib/services/deflock_tile_provider.dart';
import '../../lib/services/map_data_provider.dart';
import 'package:deflockapp/app_state.dart';
import 'package:deflockapp/services/deflock_tile_provider.dart';
import 'package:deflockapp/services/map_data_provider.dart';

class MockAppState extends Mock implements AppState {}

void main() {
group('DeflockTileProvider', () {
late DeflockTileProvider provider;

late MockAppState mockAppState;

setUp(() {
provider = DeflockTileProvider();
mockAppState = MockAppState();
when(() => mockAppState.selectedTileProvider).thenReturn(null);
when(() => mockAppState.selectedTileType).thenReturn(null);
AppState.instance = mockAppState;
});
Comment thread
dougborg marked this conversation as resolved.


tearDown(() {
// Reset to a clean mock so stubbed state doesn't leak to other tests
AppState.instance = MockAppState();
});

test('creates image provider for tile coordinates', () {
const coordinates = TileCoordinates(0, 0, 0);
const options = TileLayer(
final options = TileLayer(
urlTemplate: 'test/{z}/{x}/{y}',
);

final imageProvider = provider.getImage(coordinates, options);

expect(imageProvider, isA<DeflockTileImageProvider>());
expect((imageProvider as DeflockTileImageProvider).coordinates, equals(coordinates));
expect((imageProvider as DeflockTileImageProvider).coordinates,
equals(coordinates));
});
});

group('DeflockTileImageProvider', () {
test('generates consistent keys for same coordinates', () {
const coordinates1 = TileCoordinates(1, 2, 3);
const coordinates2 = TileCoordinates(1, 2, 3);
const coordinates3 = TileCoordinates(1, 2, 4);
const options = TileLayer(urlTemplate: 'test/{z}/{x}/{y}');

final options = TileLayer(urlTemplate: 'test/{z}/{x}/{y}');

final mapDataProvider = MapDataProvider();

final provider1 = DeflockTileImageProvider(
coordinates: coordinates1,
options: options,
Expand All @@ -56,20 +71,20 @@ void main() {
providerId: 'test_provider',
tileTypeId: 'test_type',
);

// Same coordinates should be equal
expect(provider1, equals(provider2));
expect(provider1.hashCode, equals(provider2.hashCode));

// Different coordinates should not be equal
expect(provider1, isNot(equals(provider3)));
});

test('generates different keys for different providers/types', () {
const coordinates = TileCoordinates(1, 2, 3);
const options = TileLayer(urlTemplate: 'test/{z}/{x}/{y}');
final options = TileLayer(urlTemplate: 'test/{z}/{x}/{y}');
final mapDataProvider = MapDataProvider();

final provider1 = DeflockTileImageProvider(
coordinates: coordinates,
options: options,
Expand All @@ -91,14 +106,14 @@ void main() {
providerId: 'provider_a',
tileTypeId: 'type_2',
);

// Different providers should not be equal (even with same coordinates)
expect(provider1, isNot(equals(provider2)));
expect(provider1.hashCode, isNot(equals(provider2.hashCode)));

// Different tile types should not be equal (even with same coordinates and provider)
expect(provider1, isNot(equals(provider3)));
expect(provider1.hashCode, isNot(equals(provider3.hashCode)));
});
});
}
}
30 changes: 0 additions & 30 deletions test/widget_test.dart

This file was deleted.