blob: eefffa12deeb66f91f61045eb36ba33b9b504653 [file] [log] [blame]
// Copyright 2019 The Fuchsia 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:fidl_fuchsia_ui_shortcut/fidl_async.dart' as ui_shortcut
show RegistryProxy;
import 'package:flutter/material.dart';
import 'package:fuchsia_logger/logger.dart';
import 'package:mockito/mockito.dart';
// ignore_for_file: implementation_imports
import 'package:simple_browser/src/blocs/tabs_bloc.dart';
import 'package:simple_browser/src/utils/browser_shortcuts.dart';
import 'package:test/test.dart';
void main() {
late MockRegistryProxy mockRegistryProxy;
late MockTabsBloc mockTabsBloc;
const List<String> defaultKeys = [
'newTab',
'closeTab',
'goBack',
'goForward',
'refresh',
'previousTab',
'nextTab'
];
setupLogger(name: 'browser_shortcuts_test');
setUp(() {
mockRegistryProxy = MockRegistryProxy();
mockTabsBloc = MockTabsBloc();
});
test('Should apply the given action map to BrowserShortcuts', () {
Map<String, VoidCallback> testActions = {
'action1': () {},
'action2': () {},
'action3': () {},
};
BrowserShortcuts bs = BrowserShortcuts(
tabsBloc: mockTabsBloc, //tabsBloc,
shortcutRegistry: mockRegistryProxy,
actions: testActions,
);
expect(bs.actions.length, 3, reason: '''Expected 3 shortcuts,
but actually ${bs.actions.length} shortcuts.''');
testActions.forEach((key, value) {
expect(bs.actions.containsKey(key), true,
reason: 'Expected to have $key, but does not.');
});
for (String key in defaultKeys) {
expect(bs.actions.containsKey(key), false,
reason: 'Expected not to have $key, but does.');
}
});
}
class MockRegistryProxy extends Mock implements ui_shortcut.RegistryProxy {}
class MockTabsBloc extends Mock implements TabsBloc {}