test: move theme test files into their own folder within test/src
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
test('AvatarThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const AvatarThemeData(), const AvatarThemeData().copyWith());
|
||||
expect(const AvatarThemeData().hashCode,
|
||||
const AvatarThemeData().copyWith().hashCode);
|
||||
});
|
||||
|
||||
group('AvatarThemeData lerps correctly', () {
|
||||
test('Lerp completely', () {
|
||||
expect(
|
||||
const AvatarThemeData()
|
||||
.lerp(_avatarThemeDataControl1, _avatarThemeDataControl2, 1),
|
||||
_avatarThemeDataControl2);
|
||||
});
|
||||
|
||||
test('Lerp halfway', () {
|
||||
expect(
|
||||
const AvatarThemeData()
|
||||
.lerp(_avatarThemeDataControl1, _avatarThemeDataControl2, 0.5),
|
||||
_avatarThemeDataControlMidLerp);
|
||||
});
|
||||
});
|
||||
|
||||
test('Merging two AvatarThemeData results in the latter', () {
|
||||
expect(_avatarThemeDataControl1.merge(_avatarThemeDataControl2),
|
||||
_avatarThemeDataControl2);
|
||||
});
|
||||
}
|
||||
|
||||
const _avatarThemeDataControl1 = AvatarThemeData();
|
||||
|
||||
final _avatarThemeDataControlMidLerp = AvatarThemeData(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
constraints: const BoxConstraints.tightFor(
|
||||
height: 33,
|
||||
width: 33,
|
||||
),
|
||||
);
|
||||
|
||||
final _avatarThemeDataControl2 = AvatarThemeData(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
constraints: const BoxConstraints.tightFor(
|
||||
height: 34,
|
||||
width: 34,
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart' hide TextTheme;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
test('ChannelHeaderThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const ChannelHeaderThemeData(),
|
||||
const ChannelHeaderThemeData().copyWith());
|
||||
expect(const ChannelHeaderThemeData().hashCode,
|
||||
const ChannelHeaderThemeData().copyWith().hashCode);
|
||||
});
|
||||
|
||||
group('ChannelHeaderThemeData lerps', () {
|
||||
test(
|
||||
'''Light ChannelHeaderThemeData lerps completely to dark ChannelHeaderThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const ChannelHeaderThemeData()
|
||||
.lerp(_channelThemeControl, _channelThemeControlDark, 1),
|
||||
_channelThemeControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light ChannelHeaderThemeData lerps halfway to dark ChannelHeaderThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const ChannelHeaderThemeData()
|
||||
.lerp(_channelThemeControl, _channelThemeControlDark, 0.5),
|
||||
_channelThemeControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark ChannelHeaderThemeData lerps completely to light ChannelHeaderThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const ChannelHeaderThemeData()
|
||||
.lerp(_channelThemeControlDark, _channelThemeControl, 1),
|
||||
_channelThemeControl);
|
||||
});
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(_channelThemeControl.merge(_channelThemeControlDark),
|
||||
_channelThemeControlDark);
|
||||
});
|
||||
}
|
||||
|
||||
final _channelThemeControl = ChannelHeaderThemeData(
|
||||
avatarTheme: AvatarThemeData(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
constraints: const BoxConstraints.tightFor(
|
||||
height: 40,
|
||||
width: 40,
|
||||
),
|
||||
),
|
||||
color: const Color(0xff101418),
|
||||
titleStyle: TextTheme.light().headlineBold.copyWith(
|
||||
color: const Color(0xffffffff),
|
||||
),
|
||||
subtitleStyle: TextTheme.light().footnote.copyWith(
|
||||
color: const Color(0xff7a7a7a),
|
||||
),
|
||||
);
|
||||
|
||||
final _channelThemeControlMidLerp = ChannelHeaderThemeData(
|
||||
avatarTheme: AvatarThemeData(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
constraints: const BoxConstraints.tightFor(
|
||||
height: 40,
|
||||
width: 40,
|
||||
),
|
||||
),
|
||||
color: ColorTheme.light().barsBg,
|
||||
titleStyle: TextTheme.light().headlineBold,
|
||||
subtitleStyle: TextTheme.light().footnote.copyWith(
|
||||
color: const Color(0xff7A7A7A),
|
||||
),
|
||||
);
|
||||
|
||||
final _channelThemeControlDark = ChannelHeaderThemeData(
|
||||
avatarTheme: AvatarThemeData(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
constraints: const BoxConstraints.tightFor(
|
||||
height: 40,
|
||||
width: 40,
|
||||
),
|
||||
),
|
||||
color: ColorTheme.dark().barsBg,
|
||||
titleStyle: TextTheme.dark().headlineBold,
|
||||
subtitleStyle: TextTheme.dark().footnote.copyWith(
|
||||
color: const Color(0xff7A7A7A),
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,119 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
test('ChannelListViewThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const ChannelListViewThemeData(),
|
||||
const ChannelListViewThemeData().copyWith());
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light ChannelListViewThemeData lerps completely to dark ChannelListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const ChannelListViewThemeData().lerp(_channelListViewThemeDataControl,
|
||||
_channelListViewThemeDataControlDark, 1),
|
||||
_channelListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light ChannelListViewThemeData lerps halfway to dark ChannelListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const ChannelListViewThemeData().lerp(_channelListViewThemeDataControl,
|
||||
_channelListViewThemeDataControlDark, 0.5),
|
||||
_channelListViewThemeDataControlHalfLerp);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark ChannelListViewThemeData lerps completely to light ChannelListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const ChannelListViewThemeData().lerp(
|
||||
_channelListViewThemeDataControlDark,
|
||||
_channelListViewThemeDataControl,
|
||||
1),
|
||||
_channelListViewThemeDataControl);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_channelListViewThemeDataControl
|
||||
.merge(_channelListViewThemeDataControlDark),
|
||||
_channelListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no ChannelListViewThemeData returns default light theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: StreamChannel(
|
||||
channel: MockChannel(),
|
||||
child: const ChannelListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final channelListViewTheme = ChannelListViewTheme.of(_context);
|
||||
expect(channelListViewTheme.backgroundColor,
|
||||
_channelListViewThemeDataControl.backgroundColor);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no ChannelListViewThemeData returns default dark theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
streamChatThemeData: StreamChatThemeData.dark(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: StreamChannel(
|
||||
channel: MockChannel(),
|
||||
child: const MessageListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final channelListViewTheme = ChannelListViewTheme.of(_context);
|
||||
expect(channelListViewTheme.backgroundColor,
|
||||
_channelListViewThemeDataControlDark.backgroundColor);
|
||||
});
|
||||
}
|
||||
|
||||
final _channelListViewThemeDataControl = ChannelListViewThemeData(
|
||||
backgroundColor: ColorTheme.light().appBg,
|
||||
);
|
||||
|
||||
const _channelListViewThemeDataControlHalfLerp = ChannelListViewThemeData(
|
||||
backgroundColor: Color(0xff818384),
|
||||
);
|
||||
|
||||
final _channelListViewThemeDataControlDark = ChannelListViewThemeData(
|
||||
backgroundColor: ColorTheme.dark().appBg,
|
||||
);
|
||||
@@ -0,0 +1,185 @@
|
||||
import 'package:flutter/material.dart' hide TextTheme;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
class MockStreamChatClient extends Mock implements StreamChatClient {}
|
||||
|
||||
void main() {
|
||||
test('GalleryFooterThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const GalleryFooterThemeData(),
|
||||
const GalleryFooterThemeData().copyWith());
|
||||
expect(const GalleryFooterThemeData().hashCode,
|
||||
const GalleryFooterThemeData().copyWith().hashCode);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light GalleryFooterThemeData lerps completely to dark GalleryFooterThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const GalleryFooterThemeData().lerp(_galleryFooterThemeDataControl,
|
||||
_galleryFooterThemeDataControlDark, 1),
|
||||
_galleryFooterThemeDataControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light GalleryFooterThemeData lerps halfway to dark GalleryFooterThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const GalleryFooterThemeData().lerp(_galleryFooterThemeDataControl,
|
||||
_galleryFooterThemeDataControlDark, 0.5),
|
||||
_galleryFooterThemeDataControlMidLerp);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark GalleryFooterThemeData lerps completely to light GalleryFooterThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const GalleryFooterThemeData().lerp(_galleryFooterThemeDataControlDark,
|
||||
_galleryFooterThemeDataControl, 1),
|
||||
_galleryFooterThemeDataControl);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_galleryFooterThemeDataControl
|
||||
.merge(_galleryFooterThemeDataControlDark),
|
||||
_galleryFooterThemeDataControlDark);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_galleryFooterThemeDataControlDark
|
||||
.merge(_galleryFooterThemeDataControl),
|
||||
_galleryFooterThemeDataControl);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no GalleryFooterThemeData returns default light theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockStreamChatClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
appBar: GalleryFooter(
|
||||
message: Message(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final imageFooterTheme = GalleryFooterTheme.of(_context);
|
||||
expect(imageFooterTheme.backgroundColor,
|
||||
_galleryFooterThemeDataControl.backgroundColor);
|
||||
expect(imageFooterTheme.shareIconColor,
|
||||
_galleryFooterThemeDataControl.shareIconColor);
|
||||
expect(imageFooterTheme.titleTextStyle,
|
||||
_galleryFooterThemeDataControl.titleTextStyle);
|
||||
expect(imageFooterTheme.gridIconButtonColor,
|
||||
_galleryFooterThemeDataControl.gridIconButtonColor);
|
||||
expect(imageFooterTheme.bottomSheetBarrierColor,
|
||||
_galleryFooterThemeDataControl.bottomSheetBarrierColor);
|
||||
expect(imageFooterTheme.bottomSheetBackgroundColor,
|
||||
_galleryFooterThemeDataControl.bottomSheetBackgroundColor);
|
||||
expect(imageFooterTheme.bottomSheetCloseIconColor,
|
||||
_galleryFooterThemeDataControl.bottomSheetCloseIconColor);
|
||||
expect(imageFooterTheme.bottomSheetPhotosTextStyle,
|
||||
_galleryFooterThemeDataControl.bottomSheetPhotosTextStyle);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no GalleryFooterThemeData returns default dark theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockStreamChatClient(),
|
||||
streamChatThemeData: StreamChatThemeData.dark(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
appBar: GalleryFooter(
|
||||
message: Message(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final imageFooterTheme = GalleryFooterTheme.of(_context);
|
||||
expect(imageFooterTheme.backgroundColor,
|
||||
_galleryFooterThemeDataControlDark.backgroundColor);
|
||||
expect(imageFooterTheme.shareIconColor,
|
||||
_galleryFooterThemeDataControlDark.shareIconColor);
|
||||
expect(imageFooterTheme.titleTextStyle,
|
||||
_galleryFooterThemeDataControlDark.titleTextStyle);
|
||||
expect(imageFooterTheme.gridIconButtonColor,
|
||||
_galleryFooterThemeDataControlDark.gridIconButtonColor);
|
||||
expect(imageFooterTheme.bottomSheetBarrierColor,
|
||||
_galleryFooterThemeDataControlDark.bottomSheetBarrierColor);
|
||||
expect(imageFooterTheme.bottomSheetBackgroundColor,
|
||||
_galleryFooterThemeDataControlDark.bottomSheetBackgroundColor);
|
||||
expect(imageFooterTheme.bottomSheetCloseIconColor,
|
||||
_galleryFooterThemeDataControlDark.bottomSheetCloseIconColor);
|
||||
expect(imageFooterTheme.bottomSheetPhotosTextStyle,
|
||||
_galleryFooterThemeDataControlDark.bottomSheetPhotosTextStyle);
|
||||
});
|
||||
}
|
||||
|
||||
// Light theme control
|
||||
final _galleryFooterThemeDataControl = GalleryFooterThemeData(
|
||||
backgroundColor: ColorTheme.light().barsBg,
|
||||
shareIconColor: ColorTheme.light().textHighEmphasis,
|
||||
titleTextStyle: TextTheme.light().headlineBold,
|
||||
gridIconButtonColor: ColorTheme.light().textHighEmphasis,
|
||||
bottomSheetBackgroundColor: ColorTheme.light().barsBg,
|
||||
bottomSheetBarrierColor: ColorTheme.light().overlay,
|
||||
bottomSheetCloseIconColor: ColorTheme.light().textHighEmphasis,
|
||||
bottomSheetPhotosTextStyle: TextTheme.light().headlineBold,
|
||||
);
|
||||
|
||||
// Mid-lerp theme control
|
||||
const _galleryFooterThemeDataControlMidLerp = GalleryFooterThemeData(
|
||||
backgroundColor: Color(0xff87898b),
|
||||
shareIconColor: Color(0xff7f7f7f),
|
||||
titleTextStyle: TextStyle(
|
||||
color: Color(0xff7f7f7f),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
gridIconButtonColor: Color(0xff7f7f7f),
|
||||
bottomSheetBarrierColor: Color(0x4c000000),
|
||||
bottomSheetBackgroundColor: Color(0xff87898b),
|
||||
bottomSheetPhotosTextStyle: TextStyle(
|
||||
color: Color(0xff7f7f7f),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
bottomSheetCloseIconColor: Color(0xff7f7f7f),
|
||||
);
|
||||
|
||||
// Dark theme control
|
||||
final _galleryFooterThemeDataControlDark = GalleryFooterThemeData(
|
||||
backgroundColor: ColorTheme.dark().barsBg,
|
||||
shareIconColor: ColorTheme.dark().textHighEmphasis,
|
||||
titleTextStyle: TextTheme.dark().headlineBold,
|
||||
gridIconButtonColor: ColorTheme.dark().textHighEmphasis,
|
||||
bottomSheetBackgroundColor: ColorTheme.dark().barsBg,
|
||||
bottomSheetBarrierColor: ColorTheme.dark().overlay,
|
||||
bottomSheetCloseIconColor: ColorTheme.dark().textHighEmphasis,
|
||||
bottomSheetPhotosTextStyle: TextTheme.dark().headlineBold,
|
||||
);
|
||||
@@ -0,0 +1,183 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
class MockStreamChatClient extends Mock implements StreamChatClient {}
|
||||
|
||||
void main() {
|
||||
test('GalleryHeaderThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const GalleryHeaderThemeData(),
|
||||
const GalleryHeaderThemeData().copyWith());
|
||||
expect(const GalleryHeaderThemeData().hashCode,
|
||||
const GalleryHeaderThemeData().copyWith().hashCode);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light GalleryHeaderThemeData lerps completely to dark GalleryHeaderThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const GalleryHeaderThemeData().lerp(_galleryHeaderThemeDataControl,
|
||||
_galleryHeaderThemeDataDarkControl, 1),
|
||||
_galleryHeaderThemeDataDarkControl);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light GalleryHeaderThemeData lerps halfway to dark GalleryHeaderThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const GalleryHeaderThemeData().lerp(_galleryHeaderThemeDataControl,
|
||||
_galleryHeaderThemeDataDarkControl, 0.5),
|
||||
_galleryHeaderThemeDataHalfLerpControl);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark GalleryHeaderThemeData lerps completely to light GalleryHeaderThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const GalleryHeaderThemeData().lerp(_galleryHeaderThemeDataDarkControl,
|
||||
_galleryHeaderThemeDataControl, 1),
|
||||
_galleryHeaderThemeDataControl);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_galleryHeaderThemeDataControl
|
||||
.merge(_galleryHeaderThemeDataDarkControl),
|
||||
_galleryHeaderThemeDataDarkControl);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no GalleryHeaderThemeData returns default light theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockStreamChatClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
appBar: GalleryHeader(
|
||||
message: Message(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final imageHeaderTheme = GalleryHeaderTheme.of(_context);
|
||||
expect(imageHeaderTheme.closeButtonColor,
|
||||
_galleryHeaderThemeDataControl.closeButtonColor);
|
||||
expect(imageHeaderTheme.backgroundColor,
|
||||
_galleryHeaderThemeDataControl.backgroundColor);
|
||||
expect(imageHeaderTheme.iconMenuPointColor,
|
||||
_galleryHeaderThemeDataControl.iconMenuPointColor);
|
||||
expect(imageHeaderTheme.titleTextStyle,
|
||||
_galleryHeaderThemeDataControl.titleTextStyle);
|
||||
expect(imageHeaderTheme.subtitleTextStyle,
|
||||
_galleryHeaderThemeDataControl.subtitleTextStyle);
|
||||
expect(imageHeaderTheme.bottomSheetBarrierColor,
|
||||
_galleryHeaderThemeDataControl.bottomSheetBarrierColor);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no GalleryHeaderThemeData returns default dark theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockStreamChatClient(),
|
||||
streamChatThemeData: StreamChatThemeData.dark(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
appBar: GalleryHeader(
|
||||
message: Message(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final imageHeaderTheme = GalleryHeaderTheme.of(_context);
|
||||
expect(imageHeaderTheme.closeButtonColor,
|
||||
_galleryHeaderThemeDataDarkControl.closeButtonColor);
|
||||
expect(imageHeaderTheme.backgroundColor,
|
||||
_galleryHeaderThemeDataDarkControl.backgroundColor);
|
||||
expect(imageHeaderTheme.iconMenuPointColor,
|
||||
_galleryHeaderThemeDataDarkControl.iconMenuPointColor);
|
||||
expect(imageHeaderTheme.titleTextStyle,
|
||||
_galleryHeaderThemeDataDarkControl.titleTextStyle);
|
||||
expect(imageHeaderTheme.subtitleTextStyle,
|
||||
_galleryHeaderThemeDataDarkControl.subtitleTextStyle);
|
||||
expect(imageHeaderTheme.bottomSheetBarrierColor,
|
||||
_galleryHeaderThemeDataDarkControl.bottomSheetBarrierColor);
|
||||
});
|
||||
}
|
||||
|
||||
// Light theme test control.
|
||||
final _galleryHeaderThemeDataControl = GalleryHeaderThemeData(
|
||||
closeButtonColor: const Color(0xff000000),
|
||||
backgroundColor: const Color(0xffffffff),
|
||||
iconMenuPointColor: const Color(0xff000000),
|
||||
titleTextStyle: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
subtitleTextStyle: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.black,
|
||||
).copyWith(
|
||||
color: const Color(0xff7A7A7A),
|
||||
),
|
||||
bottomSheetBarrierColor: const Color.fromRGBO(0, 0, 0, 0.2),
|
||||
);
|
||||
|
||||
// Light theme test control.
|
||||
final _galleryHeaderThemeDataHalfLerpControl = GalleryHeaderThemeData(
|
||||
closeButtonColor: const Color(0xff7f7f7f),
|
||||
backgroundColor: const Color(0xff87898b),
|
||||
iconMenuPointColor: const Color(0xff7f7f7f),
|
||||
titleTextStyle: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xff7f7f7f),
|
||||
),
|
||||
subtitleTextStyle: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xff7a7a7a),
|
||||
).copyWith(
|
||||
color: const Color(0xff7A7A7A),
|
||||
),
|
||||
bottomSheetBarrierColor: const Color(0x4c000000),
|
||||
);
|
||||
|
||||
// Dark theme test control.
|
||||
final _galleryHeaderThemeDataDarkControl = GalleryHeaderThemeData(
|
||||
closeButtonColor: const Color(0xffffffff),
|
||||
backgroundColor: const Color(0xff101418),
|
||||
iconMenuPointColor: const Color(0xffffffff),
|
||||
titleTextStyle: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
subtitleTextStyle: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.white,
|
||||
).copyWith(
|
||||
color: const Color(0xff7A7A7A),
|
||||
),
|
||||
bottomSheetBarrierColor: const Color.fromRGBO(0, 0, 0, 0.4),
|
||||
);
|
||||
@@ -0,0 +1,124 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
class MockStreamChatClient extends Mock implements StreamChatClient {}
|
||||
|
||||
void main() {
|
||||
test('MessageListViewThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const MessageListViewThemeData(),
|
||||
const MessageListViewThemeData().copyWith());
|
||||
expect(const MessageListViewThemeData().hashCode,
|
||||
const MessageListViewThemeData().copyWith().hashCode);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light MessageListViewThemeData lerps completely to dark MessageListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const MessageListViewThemeData().lerp(_messageListViewThemeDataControl,
|
||||
_messageListViewThemeDataControlDark, 1),
|
||||
_messageListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light MessageListViewThemeData lerps halfway to dark MessageListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const MessageListViewThemeData().lerp(_messageListViewThemeDataControl,
|
||||
_messageListViewThemeDataControlDark, 0.5),
|
||||
_messageListViewThemeDataControlHalfLerp);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark MessageListViewThemeData lerps completely to light MessageListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const MessageListViewThemeData().lerp(
|
||||
_messageListViewThemeDataControlDark,
|
||||
_messageListViewThemeDataControl,
|
||||
1),
|
||||
_messageListViewThemeDataControl);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_messageListViewThemeDataControl
|
||||
.merge(_messageListViewThemeDataControlDark),
|
||||
_messageListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no MessageListViewThemeData returns default light theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockStreamChatClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: StreamChannel(
|
||||
channel: MockChannel(),
|
||||
child: const MessageListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final messageListViewTheme = MessageListViewTheme.of(_context);
|
||||
expect(messageListViewTheme.backgroundColor,
|
||||
_messageListViewThemeDataControl.backgroundColor);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no MessageListViewThemeData returns default dark theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockStreamChatClient(),
|
||||
streamChatThemeData: StreamChatThemeData.dark(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: StreamChannel(
|
||||
channel: MockChannel(),
|
||||
child: const MessageListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final messageListViewTheme = MessageListViewTheme.of(_context);
|
||||
expect(messageListViewTheme.backgroundColor,
|
||||
_messageListViewThemeDataControlDark.backgroundColor);
|
||||
});
|
||||
}
|
||||
|
||||
final _messageListViewThemeDataControl = MessageListViewThemeData(
|
||||
backgroundColor: ColorTheme.light().barsBg,
|
||||
);
|
||||
|
||||
const _messageListViewThemeDataControlHalfLerp = MessageListViewThemeData(
|
||||
backgroundColor: Color(0xff87898b),
|
||||
);
|
||||
|
||||
final _messageListViewThemeDataControlDark = MessageListViewThemeData(
|
||||
backgroundColor: ColorTheme.dark().barsBg,
|
||||
);
|
||||
@@ -0,0 +1,129 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
test('MessageSearchListViewThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const MessageSearchListViewThemeData(),
|
||||
const MessageSearchListViewThemeData().copyWith());
|
||||
expect(const MessageSearchListViewThemeData().hashCode,
|
||||
const MessageSearchListViewThemeData().copyWith().hashCode);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light MessageSearchListViewThemeData lerps completely to dark MessageSearchListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const MessageSearchListViewThemeData().lerp(
|
||||
_messageSearchListViewThemeDataControl,
|
||||
_messageSearchListViewThemeDataControlDark,
|
||||
1),
|
||||
_messageSearchListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light MessageSearchListViewThemeData lerps halfway to dark MessageSearchListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const MessageSearchListViewThemeData().lerp(
|
||||
_messageSearchListViewThemeDataControl,
|
||||
_messageSearchListViewThemeDataControlDark,
|
||||
0.5),
|
||||
_messageSearchListViewThemeDataControlHalfLerp);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark MessageSearchListViewThemeData lerps completely to light MessageSearchListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const MessageSearchListViewThemeData().lerp(
|
||||
_messageSearchListViewThemeDataControlDark,
|
||||
_messageSearchListViewThemeDataControl,
|
||||
1),
|
||||
_messageSearchListViewThemeDataControl);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_messageSearchListViewThemeDataControl
|
||||
.merge(_messageSearchListViewThemeDataControlDark),
|
||||
_messageSearchListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'''Passing no MessageSearchListViewThemeData returns default light theme values''',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: MessageSearchBloc(
|
||||
child: MessageSearchListView(
|
||||
filters: Filter.in_('members', const ['test_id']),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final messageSearchListViewTheme = MessageSearchListViewTheme.of(_context);
|
||||
expect(messageSearchListViewTheme.backgroundColor,
|
||||
_messageSearchListViewThemeDataControl.backgroundColor);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'''Passing no MessageSearchListViewThemeData returns default dark theme values''',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
streamChatThemeData: StreamChatThemeData.dark(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: MessageSearchBloc(
|
||||
child: MessageSearchListView(
|
||||
filters: Filter.in_('members', const ['test_id']),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final messageSearchListViewTheme = MessageSearchListViewTheme.of(_context);
|
||||
expect(messageSearchListViewTheme.backgroundColor,
|
||||
_messageSearchListViewThemeDataControlDark.backgroundColor);
|
||||
});
|
||||
}
|
||||
|
||||
final _messageSearchListViewThemeDataControl = MessageSearchListViewThemeData(
|
||||
backgroundColor: ColorTheme.light().appBg,
|
||||
);
|
||||
|
||||
const _messageSearchListViewThemeDataControlHalfLerp =
|
||||
MessageSearchListViewThemeData(
|
||||
backgroundColor: Color(0xff818384),
|
||||
);
|
||||
|
||||
final _messageSearchListViewThemeDataControlDark =
|
||||
MessageSearchListViewThemeData(
|
||||
backgroundColor: ColorTheme.dark().appBg,
|
||||
);
|
||||
@@ -0,0 +1,114 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
test('UserListViewThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const UserListViewThemeData(),
|
||||
const UserListViewThemeData().copyWith());
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light UserListViewThemeData lerps completely to dark UserListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const UserListViewThemeData().lerp(_userListViewThemeDataControl,
|
||||
_userListViewThemeDataControlDark, 1),
|
||||
_userListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light UserListViewThemeData lerps halfway to dark UserListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const UserListViewThemeData().lerp(_userListViewThemeDataControl,
|
||||
_userListViewThemeDataControlDark, 0.5),
|
||||
_userListViewThemeDataControlHalfLerp);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark UserListViewThemeData lerps completely to light UserListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const UserListViewThemeData().lerp(_userListViewThemeDataControlDark,
|
||||
_userListViewThemeDataControl, 1),
|
||||
_userListViewThemeDataControl);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_userListViewThemeDataControl.merge(_userListViewThemeDataControlDark),
|
||||
_userListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no ChannelListViewThemeData returns default light theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return const Scaffold(
|
||||
body: UsersBloc(
|
||||
child: UserListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final userListViewTheme = UserListViewTheme.of(_context);
|
||||
expect(userListViewTheme.backgroundColor,
|
||||
_userListViewThemeDataControl.backgroundColor);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no ChannelListViewThemeData returns default dark theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
streamChatThemeData: StreamChatThemeData.dark(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return const Scaffold(
|
||||
body: UsersBloc(
|
||||
child: UserListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final userListViewTheme = UserListViewTheme.of(_context);
|
||||
expect(userListViewTheme.backgroundColor,
|
||||
_userListViewThemeDataControlDark.backgroundColor);
|
||||
});
|
||||
}
|
||||
|
||||
final _userListViewThemeDataControl = UserListViewThemeData(
|
||||
backgroundColor: ColorTheme.light().appBg,
|
||||
);
|
||||
|
||||
const _userListViewThemeDataControlHalfLerp = UserListViewThemeData(
|
||||
backgroundColor: Color(0xff818384),
|
||||
);
|
||||
|
||||
final _userListViewThemeDataControlDark = UserListViewThemeData(
|
||||
backgroundColor: ColorTheme.dark().appBg,
|
||||
);
|
||||
Reference in New Issue
Block a user