blob: b3f38d05a86fb20d6ded1c7772dc7565f9322d75 [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:devtools_app/src/config_specific/ide_theme/ide_theme.dart';
import 'package:devtools_app/src/shared/globals.dart';
import 'package:devtools_app/src/shared/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
setUpAll(() {
setGlobal(IdeTheme, IdeTheme());
});
group('Theme', () {
ThemeData theme;
test('can be used without override', () {
theme = themeFor(isDarkTheme: true, ideTheme: IdeTheme());
expect(theme.brightness, equals(Brightness.dark));
expect(
theme.scaffoldBackgroundColor,
equals(ThemeData.dark().scaffoldBackgroundColor),
);
theme = themeFor(isDarkTheme: false, ideTheme: IdeTheme());
expect(theme.brightness, equals(Brightness.light));
expect(
theme.scaffoldBackgroundColor,
equals(ThemeData.light().scaffoldBackgroundColor),
);
});
test('can be inferred from override background color', () {
theme = themeFor(
isDarkTheme: false, // Will be overridden by black BG
ideTheme: IdeTheme(backgroundColor: Colors.black),
);
expect(theme.brightness, equals(Brightness.dark));
expect(theme.scaffoldBackgroundColor, equals(Colors.black));
theme = themeFor(
isDarkTheme: true, // Will be overridden by white BG
ideTheme: IdeTheme(backgroundColor: Colors.white),
);
expect(theme.brightness, equals(Brightness.light));
expect(theme.scaffoldBackgroundColor, equals(Colors.white));
});
test('will not be inferred for colors that are not dark/light enough', () {
theme = themeFor(
isDarkTheme: false, // Will not be overridden - not dark enough
ideTheme: IdeTheme(backgroundColor: Colors.orange),
);
expect(theme.brightness, equals(Brightness.light));
expect(
theme.scaffoldBackgroundColor,
equals(ThemeData.light().scaffoldBackgroundColor),
);
theme = themeFor(
isDarkTheme: true, // Will not be overridden - not light enough
ideTheme: IdeTheme(backgroundColor: Colors.orange),
);
expect(theme.brightness, equals(Brightness.dark));
expect(
theme.scaffoldBackgroundColor,
equals(ThemeData.dark().scaffoldBackgroundColor),
);
});
test('custom background will not be used if not dark/light enough', () {
theme = themeFor(
isDarkTheme: false,
ideTheme: IdeTheme(backgroundColor: Colors.orange),
);
expect(
theme.scaffoldBackgroundColor,
equals(ThemeData.light().scaffoldBackgroundColor),
);
});
});
}