Skip to content

Commit 1794cf1

Browse files
committed
test
1 parent c8bbbd4 commit 1794cf1

File tree

5 files changed

+128
-102
lines changed

5 files changed

+128
-102
lines changed

lib/src/showcase/showcase_view.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ class ShowcaseView {
228228
if ((!force && enableAutoPlayLock) || _ids == null || !_mounted) {
229229
return;
230230
}
231-
print("Next ----");
232231
_changeSequence(ShowcaseProgressType.forward);
233232
}
234233

test/integration_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_test/flutter_test.dart';
33
import 'package:showcaseview/showcaseview.dart';
44
import 'package:showcaseview/src/tooltip/tooltip.dart';
5+
import 'package:showcaseview/src/utils/extensions.dart';
56

67
void main() {
78
group('ShowcaseView Integration Tests', () {
@@ -253,7 +254,7 @@ void main() {
253254
child: Container(
254255
width: 120,
255256
height: 80,
256-
color: Colors.red.withOpacity(0.7),
257+
color: Colors.red.reduceOpacity(0.7),
257258
child: const Center(
258259
child: Text(
259260
'Overlap Area 1',
@@ -274,7 +275,7 @@ void main() {
274275
child: Container(
275276
width: 120,
276277
height: 80,
277-
color: Colors.blue.withOpacity(0.7),
278+
color: Colors.blue.reduceOpacity(0.7),
278279
child: const Center(
279280
child: Text(
280281
'Overlap Area 2',
@@ -860,7 +861,7 @@ void main() {
860861

861862
// Complete the showcase
862863
ShowcaseView.get().next();
863-
await tester.pump(Duration(milliseconds: 100));
864+
await tester.pump(const Duration(milliseconds: 100));
864865
});
865866

866867
testWidgets(

test/overlay_test.dart

Lines changed: 80 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,71 +6,53 @@ import 'package:showcaseview/showcaseview.dart';
66

77
Color? findOverlayColor(WidgetTester tester, Color color) {
88
// Try to find a DecoratedBox or ColoredBox in the overlay
9-
print("Looking for color: $color");
109
final coloredBox =
1110
tester.widgetList(find.byType(ColoredBox)).cast<ColoredBox?>().toList();
12-
print("Found ${coloredBox.length} ColoredBox widgets");
13-
11+
1412
for (final box in coloredBox) {
1513
final boxColor = box?.color;
16-
print("Box color: $boxColor");
17-
14+
1815
if (boxColor != null) {
1916
// Check if colors match with a small tolerance
20-
final colorMatches =
21-
(boxColor.red - color.red).abs() < 0.01 &&
17+
final colorMatches = (boxColor.red - color.red).abs() < 0.01 &&
2218
(boxColor.green - color.green).abs() < 0.01 &&
2319
(boxColor.blue - color.blue).abs() < 0.01 &&
2420
(boxColor.opacity - color.opacity).abs() < 0.01;
25-
21+
2622
if (colorMatches) {
27-
print('Found matching color: $boxColor');
2823
return boxColor;
2924
}
3025
}
3126
}
32-
27+
3328
// If no exact match, try to find closest color and print for debugging
3429
if (coloredBox.isNotEmpty && coloredBox.first?.color != null) {
35-
print('Closest color found: ${coloredBox.first?.color}');
36-
print('Expected color: $color');
37-
3830
// Return the first color we find for checking in the test
3931
return coloredBox.first?.color;
4032
}
41-
42-
print('No matching colors found');
33+
4334
return null;
4435
}
4536

4637
double? findOverlayBlurSigma(WidgetTester tester) {
47-
print("Searching for blur filter...");
4838
final filters =
4939
tester.widgetList(find.byType(ImageFiltered)).cast<ImageFiltered?>();
50-
51-
print("Found ${filters.length} ImageFiltered widgets");
52-
40+
5341
for (final filter in filters) {
5442
final ImageFilter? imageFilter = filter?.imageFilter;
55-
56-
print("Filter enabled: ${filter?.enabled}");
57-
print("Filter: $imageFilter");
58-
43+
5944
if (imageFilter is ImageFilter) {
6045
// Try to extract sigma from the filter's toString (since ImageFilter.blur is private)
6146
final str = imageFilter.toString();
62-
print("Filter string: $str");
63-
47+
6448
final match = RegExp(r'ImageFilter\.blur\(\s*([0-9.]+)\s*,\s*([0-9.]+)')
6549
.firstMatch(str);
6650
if (match != null) {
6751
final sigma = double.tryParse(match.group(1)!);
68-
print("Found blur sigma: $sigma");
6952
return sigma;
7053
}
7154
}
7255
}
73-
print("No blur sigma found");
7456
return null;
7557
}
7658

@@ -398,11 +380,11 @@ void main() {
398380
description: 'High opacity overlay',
399381
overlayOpacity: 0.9,
400382
overlayColor: Colors.blue,
401-
child: Container(
383+
child: const SizedBox(
402384
width: 100,
403385
height: 50,
404386
// color: Colors.red,
405-
child: const Text('Target 1'),
387+
child: Text('Target 1'),
406388
),
407389
),
408390
Showcase(
@@ -411,11 +393,11 @@ void main() {
411393
description: 'Medium opacity overlay',
412394
overlayOpacity: 0.1,
413395
overlayColor: Colors.blue,
414-
child: Container(
396+
child: const SizedBox(
415397
width: 100,
416398
height: 50,
417399
// color: Colors.blue,
418-
child: const Text('Target 2'),
400+
child: Text('Target 2'),
419401
),
420402
),
421403
Showcase(
@@ -424,11 +406,11 @@ void main() {
424406
description: 'Low opacity overlay',
425407
overlayOpacity: 0.3,
426408
overlayColor: Colors.green,
427-
child: Container(
409+
child: const SizedBox(
428410
width: 100,
429411
height: 50,
430412
// color: Colors.green,
431-
child: const Text('Target 3'),
413+
child: Text('Target 3'),
432414
),
433415
),
434416
],
@@ -441,57 +423,68 @@ void main() {
441423
ShowcaseView.get().startShowCase([key1, key2, key3]);
442424
await tester.pump();
443425
await tester.pump(const Duration(milliseconds: 300));
444-
426+
445427
// First showcase - High opacity
446428
expect(find.byType(Overlay), findsWidgets);
447429
var color = findOverlayColor(tester, Colors.blue.withOpacity(0.9));
448430
expect(color, isNotNull);
449-
431+
450432
// Allow a small tolerance when comparing colors
451-
expect((color!.opacity - 0.9).abs() < 0.01, isTrue, reason: 'Opacity should be close to 0.9');
433+
expect(
434+
(color!.opacity - 0.9).abs() < 0.01,
435+
isTrue,
436+
reason: 'Opacity should be close to 0.9',
437+
);
452438
expect(color.red, closeTo(Colors.blue.red, 0.01));
453439
expect(color.green, closeTo(Colors.blue.green, 0.01));
454440
expect(color.blue, closeTo(Colors.blue.blue, 0.01));
455-
441+
456442
// Move to second showcase - Medium opacity
457443
ShowcaseView.get().next();
458444
await tester.pump(); // pump once to register the callback
459-
445+
460446
// Use multiple pumps with delays instead of pumpAndSettle
461447
for (int i = 0; i < 10; i++) {
462448
await tester.pump(const Duration(milliseconds: 100));
463449
}
464-
450+
465451
expect(find.byType(Overlay), findsWidgets);
466452
expect(ShowcaseView.get().getActiveShowcaseKey, key2);
467-
print('Current color: ${ShowcaseView.get().currentColor}');
468-
453+
469454
color = findOverlayColor(tester, Colors.blue.withOpacity(0.1));
470455
expect(color, isNotNull);
471-
456+
472457
// Allow a small tolerance when comparing colors
473-
expect((color!.opacity - 0.1).abs() < 0.05, isTrue, reason: 'Opacity should be close to 0.1');
458+
expect(
459+
(color!.opacity - 0.1).abs() < 0.05,
460+
isTrue,
461+
reason: 'Opacity should be close to 0.1',
462+
);
474463
expect(color.red, closeTo(Colors.blue.red, 0.01));
475464
expect(color.green, closeTo(Colors.blue.green, 0.01));
476465
expect(color.blue, closeTo(Colors.blue.blue, 0.01));
477-
466+
478467
// Move to third showcase - Low opacity
479468
ShowcaseView.get().next();
480469
await tester.pump();
481-
470+
482471
// Use multiple pumps with delays instead of pumpAndSettle
483472
for (int i = 0; i < 10; i++) {
484473
await tester.pump(const Duration(milliseconds: 100));
485474
}
486-
475+
487476
expect(find.byType(Overlay), findsWidgets);
488477
expect(ShowcaseView.get().getActiveShowcaseKey, key3);
489-
478+
490479
color = findOverlayColor(tester, Colors.green.withOpacity(0.3));
491480
expect(color, isNotNull);
492-
481+
493482
// Allow a small tolerance when comparing colors
494-
expect((color!.opacity - 0.3).abs() < 0.05, isTrue, reason: 'Opacity should be close to 0.3');
483+
expect(
484+
(color!.opacity - 0.3).abs() < 0.05,
485+
isTrue,
486+
reason: 'Opacity should be close to 0.3',
487+
);
495488
expect(color.red, closeTo(Colors.green.red, 0.01));
496489
expect(color.green, closeTo(Colors.green.green, 0.01));
497490
expect(color.blue, closeTo(Colors.green.blue, 0.01));
@@ -554,65 +547,85 @@ void main() {
554547
ShowcaseView.get().startShowCase([key1, key2, key3]);
555548
await tester.pump();
556549
await tester.pump(const Duration(milliseconds: 300));
557-
550+
558551
// First showcase - No blur
559552
expect(find.byType(Overlay), findsWidgets);
560553
var blurSigma = findOverlayBlurSigma(tester);
561-
expect(blurSigma == null || blurSigma == 0, isTrue, reason: 'First showcase should have no blur');
562-
554+
expect(
555+
blurSigma == null || blurSigma == 0,
556+
isTrue,
557+
reason: 'First showcase should have no blur',
558+
);
559+
563560
// Move to second showcase - Medium blur
564561
ShowcaseView.get().next();
565562
await tester.pump();
566-
563+
567564
// Use multiple pumps with delays instead of pumpAndSettle
568565
for (int i = 0; i < 10; i++) {
569566
await tester.pump(const Duration(milliseconds: 100));
570567
}
571-
568+
572569
// Verify the active showcase key
573570
expect(ShowcaseView.get().getActiveShowcaseKey, key2);
574571
expect(find.byType(Overlay), findsWidgets);
575-
572+
576573
// Explicitly ask to rebuild the overlay
577574
ShowcaseView.get().updateOverlay();
578575
await tester.pump();
579-
576+
580577
// Use more pumps to ensure updates are applied
581578
for (int i = 0; i < 5; i++) {
582579
await tester.pump(const Duration(milliseconds: 100));
583580
}
584-
581+
585582
// Check medium blur
586583
blurSigma = findOverlayBlurSigma(tester);
587-
expect(blurSigma, isNotNull, reason: 'Second showcase should have a blur value');
588-
expect(blurSigma, closeTo(5.0, 0.1), reason: 'Blur value should be close to 5.0');
589-
584+
expect(
585+
blurSigma,
586+
isNotNull,
587+
reason: 'Second showcase should have a blur value',
588+
);
589+
expect(
590+
blurSigma,
591+
closeTo(5.0, 0.1),
592+
reason: 'Blur value should be close to 5.0',
593+
);
594+
590595
// Move to third showcase - High blur
591596
ShowcaseView.get().next();
592597
await tester.pump();
593-
598+
594599
// Use multiple pumps with delays instead of pumpAndSettle
595600
for (int i = 0; i < 10; i++) {
596601
await tester.pump(const Duration(milliseconds: 100));
597602
}
598-
603+
599604
// Verify the active showcase key
600605
expect(ShowcaseView.get().getActiveShowcaseKey, key3);
601606
expect(find.byType(Overlay), findsWidgets);
602-
607+
603608
// Explicitly ask to rebuild the overlay
604609
ShowcaseView.get().updateOverlay();
605610
await tester.pump();
606-
611+
607612
// Use more pumps to ensure updates are applied
608613
for (int i = 0; i < 5; i++) {
609614
await tester.pump(const Duration(milliseconds: 100));
610615
}
611-
616+
612617
// Check high blur
613618
blurSigma = findOverlayBlurSigma(tester);
614-
expect(blurSigma, isNotNull, reason: 'Third showcase should have a blur value');
615-
expect(blurSigma, closeTo(10.0, 0.1), reason: 'Blur value should be close to 10.0');
619+
expect(
620+
blurSigma,
621+
isNotNull,
622+
reason: 'Third showcase should have a blur value',
623+
);
624+
expect(
625+
blurSigma,
626+
closeTo(10.0, 0.1),
627+
reason: 'Blur value should be close to 10.0',
628+
);
616629
});
617630

618631
testWidgets('Overlay with custom target shape borders',

0 commit comments

Comments
 (0)