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
25 changes: 13 additions & 12 deletions test/ability_anchor_scaling_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,16 @@ void main() {
test('drag conversion round-trips stable serialized positions', () {
const mapScale = 0.91;
final coordinateSystem = CoordinateSystem.instance;
// Circles snap to whole screen pixels, so they come back within half a
// pixel instead of exactly.
final halfPixel =
(coordinateSystem.screenToCoordinate(const Offset(1, 1)) -
coordinateSystem.screenToCoordinate(Offset.zero)) /
2;

for (final info in _representativeAbilityInfos()) {
final placed = _placedAbility(info);
Offset? expectedStoredPosition;
final snaps = info.abilityData is CircleAbility;
for (final size in <double>{
Settings.abilitySizeMin,
Settings.abilitySizeMax,
Expand All @@ -147,16 +153,15 @@ void main() {
mapScale: mapScale,
abilitySize: size,
);
expectedStoredPosition ??= restored;

expect(
restored.dx,
closeTo(expectedStoredPosition.dx, 0.0001),
closeTo(placed.position.dx, snaps ? halfPixel.dx : 0.0001),
reason: '${info.abilityData.runtimeType} x at size $size',
);
expect(
restored.dy,
closeTo(expectedStoredPosition.dy, 0.0001),
closeTo(placed.position.dy, snaps ? halfPixel.dy : 0.0001),
reason: '${info.abilityData.runtimeType} y at size $size',
);
}
Expand Down Expand Up @@ -226,7 +231,6 @@ void main() {
final coordinateSystem = CoordinateSystem.instance;

for (final agent in representativeAgents) {
Offset? expectedStoredPosition;
for (final size in <double>{
Settings.agentSizeMin,
Settings.agentSizeMax,
Expand All @@ -241,10 +245,9 @@ void main() {
renderedScreenPosition: renderedTopLeft,
agentSize: size,
);
expectedStoredPosition ??= restored;

expect(restored.dx, closeTo(expectedStoredPosition.dx, 0.0001));
expect(restored.dy, closeTo(expectedStoredPosition.dy, 0.0001));
expect(restored.dx, closeTo(agent.position.dx, 0.0001));
expect(restored.dy, closeTo(agent.position.dy, 0.0001));
}
}
});
Expand Down Expand Up @@ -301,7 +304,6 @@ void main() {
type: UtilityType.controller,
position: const Offset(356.25, 194.5),
);
Offset? expectedStoredPosition;

for (final size in <double>{
Settings.agentSizeMin,
Expand All @@ -322,10 +324,9 @@ void main() {
agentSize: size,
abilitySize: Settings.abilitySize,
);
expectedStoredPosition ??= restored;

expect(restored.dx, closeTo(expectedStoredPosition.dx, 0.0001));
expect(restored.dy, closeTo(expectedStoredPosition.dy, 0.0001));
expect(restored.dx, closeTo(utility.position.dx, 0.0001));
expect(restored.dy, closeTo(utility.position.dy, 0.0001));
}
});
});
Expand Down
4 changes: 4 additions & 0 deletions test/ability_bar_lineup_state_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,9 @@ void main() {
await _pumpHarness(tester, container: container);

expect(find.byKey(const ValueKey('ability-bar-disabled')), findsNothing);
expect(
find.byType(Draggable<AbilityInfo>),
findsNWidgets(AgentData.agents[AgentType.sova]!.abilities.length),
);
});
}
51 changes: 0 additions & 51 deletions test/ability_visibility_widgets_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -980,57 +980,6 @@ void main() {
expect(find.text('Delete lineup'), findsNothing);
});

testWidgets('lineup square icon right-click still shows menu',
(tester) async {
final container = ProviderContainer(
overrides: [
actionProvider.overrideWith(_TestActionProvider.new),
mapProvider.overrideWith(_FixedMapProvider.new),
],
);
addTearDown(() async {
await tester.pumpWidget(const SizedBox.shrink());
container.dispose();
});

final lineUp = LineUp(
id: 'lineup-icon-menu',
agent: PlacedAgent(
id: 'lineup-icon-agent',
type: AgentType.breach,
position: const Offset(20, 20),
),
ability: PlacedAbility(
id: 'lineup-icon-ability',
data: AgentData.agents[AgentType.breach]!.abilities.first,
position: Offset.zero,
),
youtubeLink: '',
images: const [],
notes: 'icon hover note',
);
container
.read(lineUpProvider.notifier)
.fromHive(LineUpGraph.fromLegacyLineUps([lineUp]));

await tester.pumpWidget(
_buildHarness(
container: container,
child: Stack(
children: [
_LineUpLandingHost(landingId: lineUp.id),
],
),
),
);
await tester.pumpAndSettle();

await _openContextMenu(tester, find.byType(AbilityWidget));

expect(find.text('Range'), findsOneWidget);
expect(find.text('Delete lineup'), findsOneWidget);
});

testWidgets('lineup note hover is icon-only', (tester) async {
final container = ProviderContainer(
overrides: [
Expand Down
14 changes: 10 additions & 4 deletions test/agent_dragable_lineup_state_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ Future<void> _pumpHarness(
),
),
);
// A tile takes its size from its icon, so it has no area to tap until the
// image decodes.
await tester.runAsync(() async {
final context = tester.element(find.byType(Row));
for (final type in [AgentType.breach, AgentType.sova]) {
await precacheImage(
AssetImage(AgentData.agents[type]!.iconPath), context);
}
});
await tester.pumpAndSettle();
}

Expand Down Expand Up @@ -118,10 +127,7 @@ void main() {

await _pumpHarness(tester, container: container);

final sovaTile = tester.widget<InkWell>(_tileFinder(AgentType.sova));
expect(sovaTile.onTap, isNotNull);

sovaTile.onTap!();
await tester.tap(_tileFinder(AgentType.sova));
await tester.pumpAndSettle();

expect(container.read(abilityBarProvider)?.type, AgentType.sova);
Expand Down
45 changes: 0 additions & 45 deletions test/authored_vision_boundary_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,51 +122,6 @@ void main() {
expect(box.bounds.bottom, closeTo(393.8, 1));
});

test('legacy provider selects the exact rendered Split boundary', () async {
final container = ProviderContainer(overrides: [
worldGeometryEnabledProvider.overrideWith((ref, map) => false),
]);
addTearDown(container.dispose);
final svg = SvgVisionBoundary.parse(
map: MapValue.split,
source: await rootBundle.loadString('assets/maps/split_map.svg'),
);

final geometry =
await container.read(viewConeGeometryProvider(MapValue.split).future);

expect(geometry, isNotNull);
final runtimeBoundary = geometry!.attackLayers.first.boundary!;
expect(
runtimeBoundary.segments.map(visionSegmentKey).toSet(),
svg.segments.map(visionSegmentKey).toSet(),
);
});

test('legacy provider selects exact rendered collision geometry for Summit',
() async {
final container = ProviderContainer(overrides: [
worldGeometryEnabledProvider.overrideWith((ref, map) => false),
]);
addTearDown(container.dispose);
final svg = SvgVisionBoundary.parse(
map: MapValue.summit,
source: await rootBundle.loadString('assets/maps/summit_map.svg'),
);

final geometry =
await container.read(viewConeGeometryProvider(MapValue.summit).future);

expect(geometry, isNotNull);
expect(geometry!.attackLayers, isNotEmpty);
expect(
geometry.attackLayers.first.boundary!.segments
.map(visionSegmentKey)
.toSet(),
svg.segments.map(visionSegmentKey).toSet(),
);
});

test('legacy walls match canonically placed SVG strokes on every map',
() async {
final container = ProviderContainer(overrides: [
Expand Down
17 changes: 0 additions & 17 deletions test/canonical_coordinates_migration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,22 +266,5 @@ void main() {
const Offset(123, 456),
);
});

test('is idempotent for current-version strategies', () {
final strategy = StrategyData(
id: 'current',
name: 'Current',
mapData: MapValue.ascent,
versionNumber: Settings.versionNumber,
lastEdited: DateTime.utc(2026, 1, 1),
folderID: null,
pages: const [],
);

expect(
identical(StrategyProvider.migrateToCurrentVersion(strategy), strategy),
isTrue,
);
});
});
}
4 changes: 1 addition & 3 deletions test/canonical_coordinates_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,12 @@ void main() {
expect(actual.height, closeTo(expectedScreen.height, 0.01));
});

test('defense rotation is a half-turn without changing canonical rotation',
() {
test('defense rotation is a half-turn', () {
const canonical = 0.42;
final displayed = CoordinateSystem.instance.rotationForSide(
canonical,
isAttack: false,
);
expect(displayed, closeTo(canonical + math.pi, 0.0001));
expect(canonical, 0.42);
});
}
12 changes: 9 additions & 3 deletions test/canonical_map_artwork_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

import 'dart:math' as math;

import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:icarus/const/map_artwork_registration.dart';
import 'package:icarus/const/maps.dart';
import 'package:icarus/widgets/canonical_map_artwork.dart';

Expand Down Expand Up @@ -28,9 +31,12 @@ void main() {
child: const SizedBox.expand(key: key)))),
));
expect(tester.getSize(find.byKey(key)), viewport);
final expected = CanonicalMapArtwork.translation(
MapValue.split, viewport,
isAttack: attack);
final viewBox = Maps.mapViewBox[MapValue.split]!;
final scale = math.min(viewport.width / viewBox.width,
viewport.height / viewBox.height);
final expected = attack
? Offset.zero
: -mapDefenseArtworkOffsetSvg[MapValue.split]! * scale;
expect((tester.getTopLeft(find.byKey(key)) - expected).distance,
lessThan(1e-9));
}
Expand Down
Loading
Loading