Files
buzz/mobile/test/features/agents/agent_avatar_backdrop_test.dart
klopez4212 962b3fdd88 Add avatar color backdrop to mobile agent creation (#9184)
Adds a blurred, saturated backdrop to mobile’s **Choose avatar** screen
that crossfades with the selected avatar or emoji color. Enlarged
artwork keeps the effect abstract; the upper fade leaves the bottom
controls clear. Supports reduced motion and high contrast.

Validated with analysis, the full mobile suite (4,518 passed),
light/dark widget previews, and an iPhone Air install with the existing
account preserved.

### Snapshots

Flutter widget captures:

| | Before | After |
|---|---|---|
| Light | ![Light
before](https://github.com/user-attachments/assets/2293d06f-8744-4949-bb6c-10e3d9975c4b)
| ![Light
after](https://github.com/user-attachments/assets/cfe75783-d2fe-4672-a2bb-c4426ed59b4f)
|
| Dark | ![Dark
before](https://github.com/user-attachments/assets/1b09e33a-1cdd-4054-8def-dd1bac0bc691)
| ![Dark
after](https://github.com/user-attachments/assets/6c903577-5cfd-4a87-9974-cbe8c9aeae60)
|

buzz-review-completed

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-06 07:21:28 -08:00

109 lines
3.3 KiB
Dart

import 'dart:convert';
import 'package:buzz/features/agents/agent_avatar_backdrop.dart';
import 'package:buzz/features/agents/agent_avatar_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
final png = base64Decode(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=',
);
final first = AgentAvatarSelection.emoji(png, '😊', 0xFFFFCC00);
final second = AgentAvatarSelection.emoji(png, '😊', 0xFF0090FF);
Widget host(
AgentAvatarSelection selection, {
bool reduced = false,
bool contrast = false,
}) => MaterialApp(
home: MediaQuery(
data: MediaQueryData(disableAnimations: reduced, highContrast: contrast),
child: SizedBox(
width: 390,
height: 800,
child: AgentAvatarBackdrop(selection: selection),
),
),
);
testWidgets('rapid selection changes settle on the latest artwork tint', (
tester,
) async {
await tester.pumpWidget(host(first));
await tester.pumpWidget(host(second));
await tester.pump(const Duration(milliseconds: 80));
expect(
find.descendant(
of: find.byType(AgentAvatarBackdrop),
matching: find.byType(ColoredBox),
),
findsNWidgets(2),
);
await tester.pumpWidget(host(first));
await tester.pumpAndSettle();
final colors = tester
.widgetList<ColoredBox>(
find.descendant(
of: find.byType(AgentAvatarBackdrop),
matching: find.byType(ColoredBox),
),
)
.map((box) => box.color);
expect(colors, [Color(first.color!)]);
expect(tester.takeException(), isNull);
});
testWidgets('reduced motion replaces the tint without a crossfade', (
tester,
) async {
await tester.pumpWidget(host(first, reduced: true));
await tester.pumpWidget(host(second, reduced: true));
await tester.pump();
expect(tester.binding.transientCallbackCount, 0);
final colors = tester
.widgetList<ColoredBox>(
find.descendant(
of: find.byType(AgentAvatarBackdrop),
matching: find.byType(ColoredBox),
),
)
.map((box) => box.color);
expect(colors, [Color(second.color!)]);
});
testWidgets(
'decorative artwork cannot intercept taps or add image semantics',
(tester) async {
final semantics = tester.ensureSemantics();
var taps = 0;
await tester.pumpWidget(
MaterialApp(
home: Stack(
children: [
Positioned.fill(
child: GestureDetector(
onTap: () => taps++,
child: const ColoredBox(color: Colors.white),
),
),
Positioned.fill(
child: AgentAvatarBackdrop(
selection: AgentAvatarSelection.image(png),
),
),
],
),
),
);
await tester.pumpAndSettle();
await tester.tapAt(const Offset(100, 100));
expect(taps, 1);
expect(find.bySemanticsLabel('Selected agent avatar'), findsNothing);
semantics.dispose();
await tester.pumpWidget(host(first, contrast: true));
expect(find.byType(ImageFiltered), findsNothing);
},
);
}