Unverified Commit d0596582 authored by Dan Field's avatar Dan Field Committed by GitHub

Fix tests that use bogus objects, update TestImageInfo interface (#64599)

parent c8f3df7e
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
// @dart = 2.8 // @dart = 2.8
import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../../painting/mocks_for_image_cache.dart'; import '../../painting/image_data.dart';
List<int> selectedTabs; List<int> selectedTabs;
...@@ -287,7 +289,7 @@ void main() { ...@@ -287,7 +289,7 @@ void main() {
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
items: List<BottomNavigationBarItem>.generate( items: List<BottomNavigationBarItem>.generate(
10, 10,
(int i) => BottomNavigationBarItem(icon: const ImageIcon(TestImageProvider(24, 23)), title: Text('$i')), (int i) => BottomNavigationBarItem(icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))), title: Text('$i')),
), ),
), ),
tabBuilder: (BuildContext context, int index) => const Text('content'), tabBuilder: (BuildContext context, int index) => const Text('content'),
...@@ -322,14 +324,14 @@ void main() { ...@@ -322,14 +324,14 @@ void main() {
CupertinoTabBar _buildTabBar({ int selectedTab = 0 }) { CupertinoTabBar _buildTabBar({ int selectedTab = 0 }) {
return CupertinoTabBar( return CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: selectedTab, currentIndex: selectedTab,
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
// @dart = 2.8 // @dart = 2.8
import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../painting/mocks_for_image_cache.dart'; import '../painting/image_data.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
/// Integration tests testing both [CupertinoPageScaffold] and [CupertinoTabScaffold]. /// Integration tests testing both [CupertinoPageScaffold] and [CupertinoTabScaffold].
...@@ -208,14 +210,14 @@ void main() { ...@@ -208,14 +210,14 @@ void main() {
home: CupertinoTabScaffold( home: CupertinoTabScaffold(
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
backgroundColor: CupertinoColors.white, backgroundColor: CupertinoColors.white,
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
), ),
...@@ -248,14 +250,14 @@ void main() { ...@@ -248,14 +250,14 @@ void main() {
), ),
child: CupertinoTabScaffold( child: CupertinoTabScaffold(
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
), ),
...@@ -298,14 +300,14 @@ void main() { ...@@ -298,14 +300,14 @@ void main() {
CupertinoApp( CupertinoApp(
home: CupertinoTabScaffold( home: CupertinoTabScaffold(
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
), ),
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
// @dart = 2.8 // @dart = 2.8
import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../painting/mocks_for_image_cache.dart'; import '../painting/image_data.dart';
import '../rendering/rendering_tester.dart'; import '../rendering/rendering_tester.dart';
List<int> selectedTabs; List<int> selectedTabs;
...@@ -44,7 +46,7 @@ void main() { ...@@ -44,7 +46,7 @@ void main() {
BottomNavigationBarItem tabGenerator(int index) { BottomNavigationBarItem tabGenerator(int index) {
return BottomNavigationBarItem( return BottomNavigationBarItem(
icon: const ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab ${index + 1}'), title: Text('Tab ${index + 1}'),
); );
} }
...@@ -1081,7 +1083,7 @@ void main() { ...@@ -1081,7 +1083,7 @@ void main() {
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
items: List<BottomNavigationBarItem>.generate( items: List<BottomNavigationBarItem>.generate(
10, 10,
(int i) => BottomNavigationBarItem(icon: const ImageIcon(TestImageProvider(24, 23)), title: Text('$i')), (int i) => BottomNavigationBarItem(icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))), title: Text('$i')),
), ),
), ),
tabBuilder: (BuildContext context, int index) => const Text('content'), tabBuilder: (BuildContext context, int index) => const Text('content'),
...@@ -1116,14 +1118,14 @@ void main() { ...@@ -1116,14 +1118,14 @@ void main() {
CupertinoTabBar _buildTabBar({ int selectedTab = 0 }) { CupertinoTabBar _buildTabBar({ int selectedTab = 0 }) {
return CupertinoTabBar( return CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: selectedTab, currentIndex: selectedTab,
......
...@@ -31,7 +31,9 @@ class TestImageInfo implements ImageInfo { ...@@ -31,7 +31,9 @@ class TestImageInfo implements ImageInfo {
} }
class TestImageProvider extends ImageProvider<int> { class TestImageProvider extends ImageProvider<int> {
const TestImageProvider(this.key, this.imageValue, { this.image }); const TestImageProvider(this.key, this.imageValue, { this.image = const TestImage() })
: assert(image != null);
final int key; final int key;
final int imageValue; final int imageValue;
final ui.Image image; final ui.Image image;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment