[cleanup] remove lib/setui/settings/*
Change-Id: Ieb6cfdece46b494e75178ee1c24ae592600f329d
diff --git a/README.md b/README.md
index eefcee8..aeed6b3 100644
--- a/README.md
+++ b/README.md
@@ -43,3 +43,4 @@
* topaz/public/lib/module_resolver: 2e13a4929
* topaz/public/lib/proposal: d32421a9d
* topaz/public/lib/user: 62cc03e
+* topaz/lib/setui/settings: 4009b4a
diff --git a/lib/setui/settings/analysis_options.yaml b/lib/setui/settings/analysis_options.yaml
deleted file mode 100644
index 49a21d7..0000000
--- a/lib/setui/settings/analysis_options.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2018 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.
-
-include: ../analysis_options.yaml
-
diff --git a/lib/setui/settings/client/BUILD.gn b/lib/setui/settings/client/BUILD.gn
deleted file mode 100644
index 6a8d315..0000000
--- a/lib/setui/settings/client/BUILD.gn
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2018 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("//build/dart/dart_library.gni")
-import("//topaz/runtime/dart/flutter_test.gni")
-
-dart_library("client") {
- package_name = "lib_setui_settings_client"
-
- sources = [
- "time_zone_controller.dart",
- "wireless_controller.dart",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.setui",
- "//topaz/lib/setui/common:common",
- "//topaz/lib/setui/flutter:flutter",
- "//topaz/lib/setui/settings/common:common",
- ]
-}
-
-flutter_test("lib_setui_settings_client_test") {
- sources = [
- "time_zone_controller_test.dart",
- # STOPSHIP(brycelee): add test back once migration to new api is complete.
- #"wireless_controller_test.dart",
- ]
-
- deps = [
- ":client",
- "//sdk/fidl/fuchsia.setui",
- "//third_party/dart-pkg/git/flutter/packages/flutter_test",
- "//third_party/dart-pkg/pub/mockito",
- "//third_party/dart-pkg/pub/test",
- ]
-}
diff --git a/lib/setui/settings/client/analysis_options.yaml b/lib/setui/settings/client/analysis_options.yaml
deleted file mode 100644
index 49a21d7..0000000
--- a/lib/setui/settings/client/analysis_options.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2018 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.
-
-include: ../analysis_options.yaml
-
diff --git a/lib/setui/settings/client/lib/time_zone_controller.dart b/lib/setui/settings/client/lib/time_zone_controller.dart
deleted file mode 100644
index 588d590..0000000
--- a/lib/setui/settings/client/lib/time_zone_controller.dart
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 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_setui/fidl.dart';
-import 'package:lib_setui_settings_common/setting_adapter.dart';
-import 'package:lib_setui_settings_common/setting_controller.dart';
-
-/// A controller class for interacting with time zones.
-class TimeZoneController extends SettingController<TimeZoneInfo> {
- TimeZoneController(SettingAdapter adapter) : super(adapter);
-
- /// Sets the system timezone to the specified zone.
- void setCurrentTimeZone(TimeZone timeZone) {
- mutate(
- Mutation.withTimeZoneMutationValue(TimeZoneMutation(
- value:
- TimeZoneInfo(available: state.available, current: timeZone))),
- null /* handles */);
- }
-}
diff --git a/lib/setui/settings/client/lib/wireless_controller.dart b/lib/setui/settings/client/lib/wireless_controller.dart
deleted file mode 100644
index 214cc78..0000000
--- a/lib/setui/settings/client/lib/wireless_controller.dart
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2018 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_setui/fidl.dart';
-import 'package:flutter/widgets.dart';
-import 'package:lib_setui_settings_common/setting_adapter.dart';
-import 'package:lib_setui_settings_common/setting_controller.dart';
-
-/// A controller for interacting with the wireless networks.
-class WirelessController extends SettingController<WirelessState> {
- WirelessController(SettingAdapter adapter) : super(adapter);
-
- final WirelessUiState uiState = WirelessUiState();
-
- /// Enter in a password and connect to the currently selected point
- Future<void> password(String password) async {
- uiState._passwordSubmitted(password);
- await _connect();
- }
-
- /// Called when the user dismisses the password dialog
- void dismissPassword() {
- uiState._passwordDismissed();
- }
-
- /// Connects to the specified [WirelessAccessPoint].
- ///
- /// If the access point requires password, then show password dialog if needed
- Future<void> select(WirelessNetwork network) async {
- if (uiState._networkSelected(network)) {
- await _connect();
- }
- }
-
- Future<void> _connect() async {
- // TODO: mutate
- uiState._reset();
- }
-}
-
-class WirelessUiState extends ChangeNotifier {
- final ValueNotifier<CurrentScreen> _screen =
- ValueNotifier(CurrentScreen.main);
- final ValueNotifier<WirelessNetwork> _selectedAccessPoint =
- ValueNotifier<WirelessNetwork>(null);
- final ValueNotifier<String> _password = ValueNotifier(null);
-
- WirelessUiState() {
- _screen.addListener(notifyListeners);
- _password.addListener(notifyListeners);
- _selectedAccessPoint.addListener(notifyListeners);
- }
-
- // Returns true if the selection should result in immediate connection
- bool _networkSelected(WirelessNetwork network) {
- _selectedAccessPoint.value = network;
- if (network.wpaAuth != WpaAuth.noneOpen) {
- _screen.value = CurrentScreen.passwordShowing;
- } else {
- _screen.value = CurrentScreen.connecting;
- return true;
- }
- return false;
- }
-
- void _passwordSubmitted(String password) {
- _password.value = password;
- _screen.value = CurrentScreen.connecting;
- }
-
- void _passwordDismissed() {
- _reset();
- }
-
- void _reset() {
- _screen.value = CurrentScreen.main;
- _selectedAccessPoint.value = null;
- _password.value = null;
- }
-
- CurrentScreen get screen => _screen.value;
- WirelessNetwork get selectedAccessPoint => _selectedAccessPoint.value;
-}
-
-enum CurrentScreen {
- main,
- passwordShowing,
- connecting,
-}
diff --git a/lib/setui/settings/client/pubspec.yaml b/lib/setui/settings/client/pubspec.yaml
deleted file mode 100644
index e044d05..0000000
--- a/lib/setui/settings/client/pubspec.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 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.
-
-name: settings_client
diff --git a/lib/setui/settings/client/test/time_zone_controller_test.dart b/lib/setui/settings/client/test/time_zone_controller_test.dart
deleted file mode 100644
index 0e982d1..0000000
--- a/lib/setui/settings/client/test/time_zone_controller_test.dart
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2018 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_setui/fidl.dart';
-import 'package:lib_setui_settings_client/time_zone_controller.dart';
-import 'package:lib_setui_settings_common/setting_adapter.dart';
-import 'package:lib_setui_settings_common/setting_model.dart';
-import 'package:lib_setui_settings_common/setting_source.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-
-class MockTestAdapter extends Mock implements SettingAdapter {}
-
-class MockTimeZoneSettingSource extends Mock
- implements SettingSource<TimeZoneInfo> {}
-
-void main() {
- // Exercises the TimeZoneController functionality, retrieving and setting the
- // time zone state.
- test('test_controller_interaction', () async {
- final TimeZone current = TimeZone(id: '1', name: 'tz1', region: []);
- // Fixture data handed back through the mock adapter.
- final TimeZoneInfo state = TimeZoneInfo(
- available: [current, TimeZone(id: '2', name: 'tz2', region: [])],
- current: current);
-
- final MockTestAdapter adapter = MockTestAdapter();
-
- // Hand back a mock setting source wrapping the fixture data.
- when(adapter.fetch(SettingType.timeZone)).thenAnswer((_) {
- final MockTimeZoneSettingSource source = MockTimeZoneSettingSource();
- when(source.state).thenReturn(state);
-
- return source;
- });
-
- final TimeZoneController controller = TimeZoneController(adapter);
-
- // Upon fetch, make sure fixture is handed back.
- final SettingModel<TimeZoneInfo> model = controller.fetch();
- expect(model.state, state);
-
- final TimeZone firstTimeZone = model.state.available[0];
-
- // When setting the time zone, make sure adapter is notified with the
- // correctly modified state.
- controller.setCurrentTimeZone(firstTimeZone);
-
- final TimeZoneInfo updatedState =
- verify(adapter.mutate(SettingType.timeZone, captureAny))
- .captured
- .single
- .timeZoneMutationValue
- .value;
-
- expect(updatedState.current, firstTimeZone);
- expect(updatedState.available, state.available);
- });
-}
diff --git a/lib/setui/settings/client/test/wireless_controller_test.dart b/lib/setui/settings/client/test/wireless_controller_test.dart
deleted file mode 100644
index 602f341..0000000
--- a/lib/setui/settings/client/test/wireless_controller_test.dart
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2018 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 'dart:math';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:lib_setui_settings_client/wireless_controller.dart';
-import 'package:lib_setui_settings_common/setting_adapter.dart';
-import 'package:lib_setui_settings_common/setting_model.dart';
-import 'package:lib_setui_settings_common/setting_source.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-
-class MockTestAdapter extends Mock implements SettingAdapter {}
-
-class MockWirelessSource extends Mock implements SettingSource<WirelessState> {}
-
-void main() {
- // Exercises the NetworkController functionality, retrieving and setting the
- // current wireless network.
- test('test_controller_interaction', () async {
- final WirelessAccessPoint accessPoint = WirelessAccessPoint(
- accessPointId: Random().nextInt(1000),
- name: 'accessPoint',
- password: null,
- rssi: Random().nextInt(1000),
- security: WirelessSecurity.secured,
- status: null);
-
- final WirelessState state = WirelessState(accessPoints: [accessPoint]);
-
- final MockTestAdapter adapter = MockTestAdapter();
-
- // Hand back a mock setting source wrapping the fixture data.
- when(adapter.fetch(SettingType.wireless)).thenAnswer((_) {
- final MockWirelessSource source = MockWirelessSource();
- when(source.state).thenReturn(state);
- return source;
- });
-
- final WirelessController controller = WirelessController(adapter);
-
- // Upon fetch, make sure fixture is handed back.
- final SettingModel<WirelessState> model = controller.fetch();
- expect(model.state, state);
-
- const String testPassword = 'TestPassword123';
-
- await controller.connect(accessPoint);
-
- expect(controller.uiState.passwordShowing, true);
- expect(controller.uiState.selectedAccessPoint, accessPoint);
-
- await controller.password(testPassword);
- expect(controller.uiState.passwordShowing, false);
-
- final WirelessState updatedState =
- verify(adapter.update(captureAny)).captured.single.data.wireless;
-
- // The state should house a single interface.
- expect(updatedState.accessPoints.length, 1);
-
- final WirelessAccessPoint updatedAccessPoint = updatedState.accessPoints[0];
-
- // id and password should match.
- expect(updatedAccessPoint.accessPointId, accessPoint.accessPointId);
- expect(updatedAccessPoint.password, testPassword);
- expect(updatedAccessPoint.status, ConnectionStatus.connected);
-
- expect(controller.uiState.selectedAccessPoint, null);
- });
-}
diff --git a/lib/setui/settings/common/BUILD.gn b/lib/setui/settings/common/BUILD.gn
deleted file mode 100644
index 2e70a9d..0000000
--- a/lib/setui/settings/common/BUILD.gn
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2018 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("//build/dart/dart_library.gni")
-import("//topaz/runtime/dart/flutter_test.gni")
-
-dart_library("common") {
- package_name = "lib_setui_settings_common"
-
- sources = [
- "setting_adapter.dart",
- "setting_controller.dart",
- "setting_model.dart",
- "setting_source.dart",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.setui",
- "//topaz/lib/setui/common:common",
- "//topaz/lib/setui/flutter:flutter",
- "//topaz/lib/setui/settings/json:fuchsia.setui.json",
- ]
-}
-
-flutter_test("lib_setui_settings_common_test") {
- sources = [
- "adapter_log_test.dart",
- "setting_controller_test.dart",
- ]
-
- deps = [
- ":common",
- "//sdk/fidl/fuchsia.setui",
- "//third_party/dart-pkg/git/flutter/packages/flutter_test",
- "//third_party/dart-pkg/pub/mockito",
- "//third_party/dart-pkg/pub/test",
- ]
-}
diff --git a/lib/setui/settings/common/analysis_options.yaml b/lib/setui/settings/common/analysis_options.yaml
deleted file mode 100644
index 49a21d7..0000000
--- a/lib/setui/settings/common/analysis_options.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2018 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.
-
-include: ../analysis_options.yaml
-
diff --git a/lib/setui/settings/common/lib/setting_adapter.dart b/lib/setui/settings/common/lib/setting_adapter.dart
deleted file mode 100644
index e0f4c72..0000000
--- a/lib/setui/settings/common/lib/setting_adapter.dart
+++ /dev/null
@@ -1,343 +0,0 @@
-// Copyright 2018 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 'dart:async';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:fidl_fuchsia_setui_json/json.dart';
-
-import 'setting_source.dart';
-
-/// An interface for accessing settings.
-///
-/// Adapters are meant for controllers, who expose a narrower interaction
-/// surface to the clients.
-abstract class SettingAdapter {
- /// Retrieves the current setting source.
- SettingSource<T> fetch<T>(SettingType settingType);
-
- /// Applies the updated values to the backend.
- Future<UpdateResponse> update(SettingsObject updatedSetting);
-
- /// Applies a mutation to the backend.
- Future<MutationResponse> mutate(SettingType settingType, Mutation mutation,
- {MutationHandles handles});
-}
-
-/// An interface for receiving setting updates.
-abstract class AdapterLogger {
- /// Invoked when fetch is requested.
- void onFetch(FetchLog log);
-
- /// Invoked when an update occurs from the client.
- void onUpdate(UpdateLog log);
-
- /// Invoked when an update response is ready.
- void onResponse(ResponseLog log);
-
- /// Invoked when a mutation occurs from client.
- void onMutation(MutationLog log);
-
- /// Invoked when an mutation response is ready.
- void onMutationResponse(MutationResponseLog log);
-
- /// Invoked when a setting is updated from the server.
- void onSettingLog(SettingLog log);
-}
-
-/// Enum class for who is responsible for the update.
-class AdapterLogType {
- static const int fetchId = 0;
- static const int updateId = 1;
- static const int settingId = 2;
- static const int responseId = 3;
- static const int mutationId = 4;
- static const int mutationResponseId = 5;
-
- final int value;
-
- factory AdapterLogType(int value) {
- switch (value) {
- case fetchId:
- return fetch;
- case updateId:
- return update;
- case settingId:
- return setting;
- case responseId:
- return response;
- case mutationId:
- return mutation;
- case mutationResponseId:
- return mutationResponse;
- default:
- return null;
- }
- }
-
- const AdapterLogType._(this.value);
-
- static const AdapterLogType fetch = AdapterLogType._(fetchId);
-
- static const AdapterLogType update = AdapterLogType._(updateId);
-
- static const AdapterLogType setting = AdapterLogType._(settingId);
-
- static const AdapterLogType response = AdapterLogType._(responseId);
-
- static const AdapterLogType mutation = AdapterLogType._(mutationId);
-
- static const AdapterLogType mutationResponse =
- AdapterLogType._(mutationResponseId);
-
- int toJson() {
- return value;
- }
-}
-
-/// Union container for an adapter log.
-class AdapterLog {
- static const String _timeKey = 'time';
- static const String _typeKey = 'type';
- static const String _dataKey = 'data';
-
- static const String _fetchType = 'fetch';
- static const String _settingType = 'setting';
- static const String _responseType = 'response';
- static const String _updateType = 'update';
- static const String _mutationType = 'mutation';
- static const String _mutationResponseType = 'mutationResponse';
-
- final DateTime time;
- final AdapterLogType type;
-
- // ignore: prefer_typing_uninitialized_variables
- final _data;
-
- const AdapterLog.withFetch(this.time, FetchLog fetch)
- : _data = fetch,
- type = AdapterLogType.fetch;
-
- const AdapterLog.withUpdate(this.time, UpdateLog update)
- : _data = update,
- type = AdapterLogType.update;
-
- const AdapterLog.withSetting(this.time, SettingLog setting)
- : _data = setting,
- type = AdapterLogType.setting;
-
- const AdapterLog.withResponse(this.time, ResponseLog response)
- : _data = response,
- type = AdapterLogType.response;
-
- const AdapterLog.withMutation(this.time, MutationLog mutation)
- : _data = mutation,
- type = AdapterLogType.mutation;
-
- const AdapterLog.withMutationResponse(
- this.time, MutationResponseLog mutationResponse)
- : _data = mutationResponse,
- type = AdapterLogType.mutationResponse;
-
- factory AdapterLog.fromJson(Map<String, dynamic> json) {
- String type = json[_typeKey];
- DateTime time = DateTime.parse(json[_timeKey]);
-
- switch (type) {
- case _fetchType:
- return AdapterLog.withFetch(time, FetchLog?.fromJson(json[_dataKey]));
- case _updateType:
- return AdapterLog.withSetting(
- time, SettingLog?.fromJson(json[_dataKey]));
- case _settingType:
- return AdapterLog.withSetting(
- time, SettingLog?.fromJson(json[_dataKey]));
- case _responseType:
- return AdapterLog.withResponse(
- time, ResponseLog?.fromJson(json[_dataKey]));
- default:
- return null;
- }
- }
-
- String _typeToString() {
- switch (type) {
- case AdapterLogType.fetch:
- return _fetchType;
- case AdapterLogType.setting:
- return _settingType;
- case AdapterLogType.response:
- return _responseType;
- case AdapterLogType.update:
- return _updateType;
- case AdapterLogType.mutation:
- return _mutationType;
- case AdapterLogType.mutationResponse:
- return _mutationResponseType;
- default:
- return null;
- }
- }
-
- Map<String, dynamic> toJson() => {
- _timeKey: time.toIso8601String(),
- _typeKey: _typeToString(),
- _dataKey: _data,
- };
-
- bool get fromClient =>
- type == AdapterLogType.fetch || type == AdapterLogType.update;
-
- UpdateLog get updateLog {
- if (type != AdapterLogType.update) {
- return null;
- }
-
- return _data;
- }
-
- FetchLog get fetchLog {
- if (type != AdapterLogType.fetch) {
- return null;
- }
-
- return _data;
- }
-
- SettingLog get settingLog {
- if (type != AdapterLogType.setting) {
- return null;
- }
-
- return _data;
- }
-
- ResponseLog get responseLog {
- if (type != AdapterLogType.response) {
- return null;
- }
-
- return _data;
- }
-
- MutationLog get mutationLog => type == AdapterLogType.mutation ? _data : null;
-
- MutationResponseLog get mutationResponseLog =>
- type == AdapterLogType.mutationResponse ? _data : null;
-}
-
-class FetchLog {
- static const String _typeKey = 'type';
-
- final SettingType type;
-
- FetchLog(this.type);
-
- factory FetchLog.fromJson(Map<String, dynamic> json) => json != null
- ? FetchLog(SettingTypeConverter.fromJson(json[_typeKey]))
- : null;
-
- Map<String, dynamic> toJson() =>
- {_typeKey: SettingTypeConverter.toJson(type)};
-}
-
-/// A container for capturing details around a service response.
-class ResponseLog {
- static const String _updateIdKey = 'update_id';
- static const String _responseKey = 'response';
-
- final int updateId;
- final UpdateResponse response;
-
- ResponseLog(this.updateId, this.response);
-
- factory ResponseLog.fromJson(Map<String, dynamic> json) => json != null
- ? ResponseLog(json[_updateIdKey],
- UpdateResponseConverter.fromJson(json[_responseKey]))
- : null;
-
- Map<String, dynamic> toJson() => {
- _updateIdKey: updateId,
- _responseKey: UpdateResponseConverter.toJson(response)
- };
-}
-
-/// A container for capturing interaction events between the client and service.
-class SettingLog {
- static const String _settingsKey = 'settings';
-
- /// The captured settings.
- final SettingsObject settings;
-
- SettingLog(this.settings);
-
- factory SettingLog.fromJson(Map<String, dynamic> json) =>
- SettingLog(SettingsObjectConverter.fromJson(json[_settingsKey]));
-
- Map<String, dynamic> toJson() => {
- _settingsKey: SettingsObjectConverter.toJson(settings),
- };
-}
-
-class UpdateLog {
- static const String _idKey = 'id';
- static const String _settingsKey = 'settings';
-
- final int id;
- final SettingsObject settings;
-
- UpdateLog(this.id, this.settings);
-
- factory UpdateLog.fromJson(Map<String, dynamic> json) => UpdateLog(
- json[_idKey], SettingsObjectConverter.fromJson(json[_settingsKey]));
-
- Map<String, dynamic> toJson() => {
- _idKey: id,
- _settingsKey: SettingsObjectConverter.toJson(settings),
- };
-}
-
-class MutationLog {
- static const String _idKey = 'id';
- static const String _settingTypeKey = 'settingType';
- static const String _mutationKey = 'mutation';
-
- final int id;
- final SettingType settingType;
- final Mutation mutation;
-
- MutationLog(this.id, this.settingType, this.mutation);
-
- factory MutationLog.fromJson(Map<String, dynamic> json) => MutationLog(
- json[_idKey],
- SettingTypeConverter.fromJson(json[_settingTypeKey]),
- MutationConverter.fromJson(json[_mutationKey]));
-
- Map<String, dynamic> toJson() => {
- _idKey: id,
- _settingTypeKey: SettingTypeConverter.toJson(settingType),
- _mutationKey: MutationConverter.toJson(mutation),
- };
-}
-
-class MutationResponseLog {
- static const String _mutationIdKey = 'mutation_id';
- static const String _responseKey = 'response';
-
- final int mutationId;
- final MutationResponse response;
-
- MutationResponseLog(this.mutationId, this.response);
-
- factory MutationResponseLog.fromJson(Map<String, dynamic> json) =>
- json != null
- ? MutationResponseLog(json[_mutationIdKey],
- MutationResponseConverter.fromJson(json[_responseKey]))
- : null;
-
- Map<String, dynamic> toJson() => {
- _mutationIdKey: mutationId,
- _responseKey: UpdateResponseConverter.toJson(response)
- };
-}
diff --git a/lib/setui/settings/common/lib/setting_controller.dart b/lib/setui/settings/common/lib/setting_controller.dart
deleted file mode 100644
index f8e6fcf..0000000
--- a/lib/setui/settings/common/lib/setting_controller.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2018 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_setui/fidl.dart';
-
-import 'setting_adapter.dart';
-import 'setting_model.dart';
-import 'setting_source.dart';
-
-/// Base controller that handles interaction with the underlying setting adapter
-/// and access to the state data.
-class SettingController<T> {
- final SettingAdapter _adapter;
- SettingSource<T> _source;
-
- SettingController(this._adapter);
-
- /// Returns a setting model that will be updated with the latest state.
- SettingModel<T> fetch() {
- _source ??= _adapter.fetch(settingType);
-
- return SettingModel<T>(_source);
- }
-
- SettingType get settingType {
- switch (T) {
- case TimeZoneInfo:
- return SettingType.timeZone;
- case WirelessState:
- return SettingType.wireless;
- case ConnectedState:
- return SettingType.connectivity;
- }
-
- throw Exception('Undefined setting type!');
- }
-
- Future<void> mutate(Mutation mutation, MutationHandles handles) async {
- await _adapter.mutate(settingType, mutation, handles: handles);
- }
-
- /// Updates the setting state to the provided version.
- Future<void> update(SettingsObject state) async {
- await _adapter.update(state);
- }
-
- /// Returns the most current data from source.
- T get state => _source.state;
-}
diff --git a/lib/setui/settings/common/lib/setting_model.dart b/lib/setui/settings/common/lib/setting_model.dart
deleted file mode 100644
index 3cec913..0000000
--- a/lib/setui/settings/common/lib/setting_model.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2018 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:lib.widgets/model.dart';
-
-import 'setting_source.dart';
-
-/// A wrapper around settings data to notify widgets on new data.
-class SettingModel<T> extends Model {
- SettingSource<T> _source;
-
- SettingModel(this._source) {
- _source.addListener((value) => notifyListeners());
- }
-
- T get state => _source.state;
-}
diff --git a/lib/setui/settings/common/lib/setting_source.dart b/lib/setui/settings/common/lib/setting_source.dart
deleted file mode 100644
index 0aa1585..0000000
--- a/lib/setui/settings/common/lib/setting_source.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2018 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 'dart:async';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-
-/// An accessor for settings.
-///
-/// [SettingSource] extends [ChangeNotifier] to provide updates on changes to
-/// owners. For example, a model may wrap [SettingSource] for the view layer and
-/// register its notify method as the change callback.
-class SettingSource<T> implements SettingListener {
- T _value;
-
- final StreamController<T> _streamController =
- StreamController<T>.broadcast();
-
- StreamSubscription<T> addListener(void callback(T value)) =>
- _streamController.stream.listen(callback);
-
- /// The current setting.
- T get state => _value;
-
- @override
- Future<Null> notify(SettingsObject object) async {
- _value = object.data.$data;
- _streamController.add(_value);
- }
-}
diff --git a/lib/setui/settings/common/pubspec.yaml b/lib/setui/settings/common/pubspec.yaml
deleted file mode 100644
index 2075d71..0000000
--- a/lib/setui/settings/common/pubspec.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 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.
-
-name: settings_common
diff --git a/lib/setui/settings/common/test/adapter_log_test.dart b/lib/setui/settings/common/test/adapter_log_test.dart
deleted file mode 100644
index 0e7a09c..0000000
--- a/lib/setui/settings/common/test/adapter_log_test.dart
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2018 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 'dart:convert';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:lib_setui_settings_common/setting_adapter.dart';
-import 'package:test/test.dart';
-
-void main() {
- // Exercises json encoding of setting log.
- test('test_setting_log_json', () async {
- final TimeZone tz1 = TimeZone(id: '1', name: 'foo', region: ['foo1']);
- final TimeZone tz2 = TimeZone(id: '2', name: 'bar', region: ['bar2']);
-
- final AdapterLog log1 = AdapterLog.withSetting(
- DateTime.now(),
- SettingLog(SettingsObject(
- settingType: SettingType.timeZone,
- data: SettingData.withTimeZoneValue(
- TimeZoneInfo(available: [tz1, tz2], current: tz2)))));
-
- final AdapterLog log2 = AdapterLog.fromJson(jsonDecode(jsonEncode(log1)));
-
- expect(log1.time, log2.time);
- expect(log1.settingLog.settings.settingType,
- log2.settingLog.settings.settingType);
-
- // FIDL parsing is covered by the fidl-gen tests.
- });
-
- // Exercises json encoding of fetch log.
- test('test_fetch_log_json', () async {
- final AdapterLog adapterLog1 = AdapterLog.withFetch(
- DateTime.now(), FetchLog(SettingType.connectivity));
-
- final AdapterLog adapterLog2 =
- AdapterLog.fromJson(jsonDecode(jsonEncode(adapterLog1)));
-
- expect(adapterLog1.fetchLog.type, adapterLog2.fetchLog.type);
- });
-}
diff --git a/lib/setui/settings/common/test/setting_controller_test.dart b/lib/setui/settings/common/test/setting_controller_test.dart
deleted file mode 100644
index 9735732..0000000
--- a/lib/setui/settings/common/test/setting_controller_test.dart
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2018 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_setui/fidl.dart';
-import 'package:lib_setui_settings_common/setting_adapter.dart';
-import 'package:lib_setui_settings_common/setting_controller.dart';
-import 'package:lib_setui_settings_common/setting_source.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-
-class MockTestAdapter extends Mock implements SettingAdapter {}
-
-void main() {
- // Make sure mappings call the correct underlying mapping.
- test('test_setting_controller_mapping', () async {
- verifyMapping<WirelessState>(SettingType.wireless);
- verifyMapping<ConnectedState>(SettingType.connectivity);
- verifyMapping<TimeZoneInfo>(SettingType.timeZone);
- });
-}
-
-void verifyMapping<T>(SettingType type) {
- final MockTestAdapter adapter = MockTestAdapter();
- when(adapter.fetch(type)).thenReturn(SettingSource<T>());
- SettingController<T>(adapter).fetch();
- verify(adapter.fetch(type));
-}
diff --git a/lib/setui/settings/json/BUILD.gn b/lib/setui/settings/json/BUILD.gn
deleted file mode 100644
index 9b40458..0000000
--- a/lib/setui/settings/json/BUILD.gn
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2018 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("//topaz/bin/dart_fidl_json/dart_fidl_json.gni")
-import("//topaz/runtime/dart/flutter_test.gni")
-
-json_fidl("fuchsia.setui.json") {
- fidl_target = "//sdk/fidl/fuchsia.setui"
-
- deps = [
- "//sdk/fidl/fuchsia.setui",
- ]
-}
diff --git a/lib/setui/settings/service/BUILD.gn b/lib/setui/settings/service/BUILD.gn
deleted file mode 100644
index bc8cccd..0000000
--- a/lib/setui/settings/service/BUILD.gn
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 2018 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("//build/dart/dart_library.gni")
-import("//topaz/runtime/dart/flutter_test.gni")
-
-dart_library("service") {
- package_name = "lib_setui_service"
-
- sources = [
- "service.dart",
- "src/setui_setting_controller.dart",
- "src/network_controller.dart",
- "src/intl_controller.dart",
- "src/connectivity_controller.dart",
- "src/timezone_controller.dart",
- "src/intl/intl_settings_util.dart",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.netstack",
- "//sdk/fidl/fuchsia.setui",
- "//sdk/fidl/fuchsia.stash",
- "//sdk/fidl/fuchsia.timezone",
- "//sdk/fidl/fuchsia.wlan.service",
- "//topaz/lib/settings:lib.settings",
- "//topaz/lib/setui/settings/common:common",
- "//topaz/public/dart/fidl",
- "//topaz/public/dart/widgets:lib.widgets",
- "//topaz/public/lib/app/dart",
- "//zircon/public/fidl/fuchsia-net:fuchsia-net",
- ]
-}
-
-flutter_test("lib_setui_service_test") {
- sources = [
- "intl/intl_settings_util_test.dart",
-
- # STOPSHIP(brycelee): add test back once migration to new api is complete.
- # "network_controller_test.dart",
- "intl_controller_test.dart",
- ]
-
- deps = [
- ":service",
- "//third_party/dart-pkg/git/flutter/packages/flutter_test",
- "//third_party/dart-pkg/pub/mockito",
- "//third_party/dart-pkg/pub/test",
- ]
-}
diff --git a/lib/setui/settings/service/analysis_options.yaml b/lib/setui/settings/service/analysis_options.yaml
deleted file mode 100644
index e375f1c..0000000
--- a/lib/setui/settings/service/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 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.
-
-include: ../analysis_options.yaml
\ No newline at end of file
diff --git a/lib/setui/settings/service/lib/service.dart b/lib/setui/settings/service/lib/service.dart
deleted file mode 100644
index a301379..0000000
--- a/lib/setui/settings/service/lib/service.dart
+++ /dev/null
@@ -1,114 +0,0 @@
-import 'dart:async';
-
-import 'package:fidl/fidl.dart';
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:lib_setui_settings_common/setting_adapter.dart';
-import 'package:lib_setui_settings_common/setting_source.dart';
-
-/// Library that wraps the underlying setUi service.
-///
-/// Can be used to swap out between different implementations.
-/// A [SetUiListenerBinder] can be passed in to provide alternative
-/// binding forms (such as in linux host tests).
-class SetUiServiceAdapter implements SettingAdapter {
- final SetUiService _service;
- final SetUiListenerBinder _listenerBinder;
- final Map<SettingType, SettingSource> _sources = {};
- final AdapterLogger _logger;
-
- int nextUpdateId = 0;
-
- int _nextMutationId = 0;
-
- factory SetUiServiceAdapter(
- {SetUiService service,
- SetUiListenerBinder binder = _bindListener,
- AdapterLogger logger}) {
- final SetUiServiceAdapter adapter = service != null
- ? SetUiServiceAdapter.withService(service, binder, logger)
- : SetUiServiceAdapter._local(binder, logger);
-
- return adapter;
- }
-
- SetUiServiceAdapter.withService(
- this._service, this._listenerBinder, this._logger);
-
- SetUiServiceAdapter._local(this._listenerBinder, this._logger)
- : _service = null;
-
- /// Gets the setting from the service with the given [SettingType].
- ///
- /// [T] must be the type returned by the service for the given SettingType
- /// as documented in fuchsia.setui.types.fidl.
- @override
- SettingSource<T> fetch<T>(SettingType settingType) {
- if (!_sources.containsKey(settingType)) {
- _sources[settingType] = ObservableSettingSource<T>(_logger);
- }
-
- final ObservableSettingSource<T> notifier = _sources[settingType];
-
- _service.listen(settingType, _listenerBinder(notifier));
- _logger?.onFetch(FetchLog(settingType));
-
- return notifier;
- }
-
- /// Updates the setting based on [SettingsObject]'s type.
- @override
- Future<UpdateResponse> update(SettingsObject object) async {
- final int nextUpdateId = this.nextUpdateId++;
-
- _logger?.onUpdate(UpdateLog(nextUpdateId, object));
-
- Completer<UpdateResponse> c = Completer<UpdateResponse>();
-
- _service.update(object, (response) {
- _logger?.onResponse(ResponseLog(nextUpdateId, response));
- c.complete(response);
- });
-
- return c.future;
- }
-
- @override
- Future<MutationResponse> mutate(SettingType settingType, Mutation mutation,
- {MutationHandles handles}) async {
- final int nextMutationId = _nextMutationId++;
-
- _logger?.onMutation(MutationLog(nextMutationId, settingType, mutation));
-
- Completer<MutationResponse> completer = Completer<MutationResponse>();
-
- void callback(MutationResponse response) {
- completer.complete(response);
- }
-
- if (handles != null) {
- _service.interactiveMutate(settingType, mutation, handles, callback);
- } else {
- _service.mutate(settingType, mutation, callback);
- }
- return completer.future;
- }
-}
-
-// A source that can be instrumented to capture updates.
-class ObservableSettingSource<T> extends SettingSource<T> {
- final AdapterLogger _logger;
-
- ObservableSettingSource(this._logger);
-
- @override
- Future<Null> notify(SettingsObject object) {
- _logger?.onSettingLog(SettingLog(object));
- return super.notify(object);
- }
-}
-
-typedef SetUiListenerBinder = InterfaceHandle<SettingListener> Function(
- SettingListener impl);
-
-InterfaceHandle<SettingListener> _bindListener(SettingListener impl) =>
- SettingListenerBinding().wrap(impl);
diff --git a/lib/setui/settings/service/lib/src/connectivity_controller.dart b/lib/setui/settings/service/lib/src/connectivity_controller.dart
deleted file mode 100644
index 60cd462..0000000
--- a/lib/setui/settings/service/lib/src/connectivity_controller.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-import 'dart:async';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:fidl_fuchsia_net/fidl.dart' as net;
-import 'package:lib.app.dart/app.dart';
-
-import 'setui_setting_controller.dart';
-
-// TODO: Implement and override applyMutation.
-class ConnectivityController extends SetUiSettingController {
- net.ConnectivityProxy _connectivity;
- bool _reachable;
-
- @override
- Future<void> close() async {
- _connectivity.ctrl.close();
- }
-
- @override
- Future<void> initialize() async {
- Completer<void> completer = Completer();
-
- _connectivity = net.ConnectivityProxy();
- connectToService(StartupContext.fromStartupInfo().environmentServices,
- _connectivity.ctrl);
-
- _connectivity.onNetworkReachable = (reachable) {
- // Wait for initital state before being done initializing.
- if (_reachable != reachable) {
- _reachable = reachable;
- _connectivity.onNetworkReachable = _updateReachable;
- completer.complete();
- }
- };
- return completer.future;
- }
-
- void _updateReachable(bool reachable) {
- if (_reachable != reachable) {
- _reachable = reachable;
- notifyListeners();
- }
- }
-
- @override
- SettingsObject get value => SettingsObject(
- settingType: SettingType.connectivity,
- data: SettingData.withConnectivity(ConnectedState(
- reachability: _reachable ? Reachability.wan : Reachability.unknown)));
-}
diff --git a/lib/setui/settings/service/lib/src/intl/intl_settings_util.dart b/lib/setui/settings/service/lib/src/intl/intl_settings_util.dart
deleted file mode 100644
index 5797831..0000000
--- a/lib/setui/settings/service/lib/src/intl/intl_settings_util.dart
+++ /dev/null
@@ -1,72 +0,0 @@
-// 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.
-
-/// Utility methods for working with the [IntlSettings] FIDL struct.
-library intl_settings_util;
-
-import 'dart:convert';
-import 'package:fidl_fuchsia_setui/fidl.dart';
-
-IntlSettings applyMutation(IntlSettings settings, Mutation mutation) {
- switch (mutation.$tag) {
- case MutationTag.localesMutationValue:
- return setLocales(settings, mutation.localesMutationValue);
- case MutationTag.hourCycleMutationValue:
- return setHourCycle(settings, mutation.hourCycleMutationValue);
- case MutationTag.temperatureUnitMutationValue:
- return setTemperatureUnit(
- settings, mutation.temperatureUnitMutationValue);
- default:
- throw ArgumentError('Unsupported mutation type');
- }
-}
-
-IntlSettings setLocales(IntlSettings settings, LocalesMutation mutation) {
- return IntlSettings(
- locales: mutation.locales,
- hourCycle: settings.hourCycle,
- temperatureUnit: settings.temperatureUnit);
-}
-
-IntlSettings setHourCycle(IntlSettings settings, HourCycleMutation mutation) {
- if (settings.hourCycle != mutation.hourCycle) {
- return IntlSettings(
- locales: settings.locales,
- hourCycle: mutation.hourCycle,
- temperatureUnit: settings.temperatureUnit);
- }
- return settings;
-}
-
-IntlSettings setTemperatureUnit(
- IntlSettings settings, TemperatureUnitMutation mutation) {
- if (settings.temperatureUnit != mutation.temperatureUnit) {
- return IntlSettings(
- locales: settings.locales,
- hourCycle: settings.hourCycle,
- temperatureUnit: mutation.temperatureUnit);
- }
- return settings;
-}
-
-/// JSON encoder, since there's no standard one for FIDL.
-String toJson(IntlSettings settings) {
- Map<String, dynamic> map = {
- 'locales': settings.locales,
- 'hour_cycle': settings.hourCycle == HourCycle.h12 ? 'h12' : 'h23',
- 'temperature_unit': settings.temperatureUnit == TemperatureUnit.celsius
- ? 'celsius'
- : 'fahrenheit'
- };
- return jsonEncode(map);
-}
-
-/// JSON decoder, since there's no standard one for FIDL.
-IntlSettings fromJson(String json) {
- Map<String, dynamic> parsed = jsonDecode(json);
- return IntlSettings(
- locales: List<String>.from(parsed['locales']),
- hourCycle: HourCycle.$valuesMap[parsed['hour_cycle']],
- temperatureUnit: TemperatureUnit.$valuesMap[parsed['temperature_unit']]);
-}
diff --git a/lib/setui/settings/service/lib/src/intl_controller.dart b/lib/setui/settings/service/lib/src/intl_controller.dart
deleted file mode 100644
index 268b3ff..0000000
--- a/lib/setui/settings/service/lib/src/intl_controller.dart
+++ /dev/null
@@ -1,128 +0,0 @@
-// 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 'dart:async';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:fidl_fuchsia_stash/fidl.dart';
-import 'package:fidl_fuchsia_sys/fidl.dart';
-import 'package:lib.app.dart/app.dart';
-import 'package:meta/meta.dart';
-import 'intl/intl_settings_util.dart' as intl_util;
-
-import 'setui_setting_controller.dart';
-
-/// An implementation of [SetUiSettingController] for internationalization
-/// settings. Currently uses Stash as a backing store.
-class IntlSettingsController extends SetUiSettingController {
- static const String _stashStoreName = 'INTL_SETTINGS';
- @visibleForTesting
- static const String stashKey = 'INTL_SETTINGS_KEY';
-
- final StoreAccessorWrapperProvider _storeAccessorWrapperProvider;
- StoreAccessorWrapper _storeAccessorWrapper;
- IntlSettings _currentIntlSettings;
-
- /// Default constructor
- IntlSettingsController() : this.withStashProvider(createStoreAccessorWrapper);
-
- /// Constructor that takes a custom [StoreAccessorWrapperProvider], primarily
- /// for use in tests.
- IntlSettingsController.withStashProvider(
- StoreAccessorWrapperProvider storeAccessorWrapperProvider)
- : _storeAccessorWrapperProvider = storeAccessorWrapperProvider;
-
- @override
- Future<void> close() async {
- _storeAccessorWrapper.close();
- _currentIntlSettings = null;
- }
-
- @override
- Future<void> initialize() {
- Completer<void> completer = Completer();
-
- _storeAccessorWrapper = _storeAccessorWrapperProvider();
- _storeAccessorWrapper.accessor.getValue(stashKey, (value) {
- if (value != null && value.stringval != null) {
- // TODO: Parse error handling? Should the future ever fail?
- _currentIntlSettings = intl_util.fromJson(value.stringval);
- }
- completer.complete();
- });
-
- return completer.future;
- }
-
- @override
- SettingsObject get value => SettingsObject(
- settingType: SettingType.intl,
- data: SettingData.withIntl(_currentIntlSettings));
-
- @override
- Future<ReturnCode> applyMutation(Mutation mutation,
- {MutationHandles handles}) async {
- _currentIntlSettings =
- intl_util.applyMutation(_currentIntlSettings, mutation);
- final json = intl_util.toJson(_currentIntlSettings);
- _storeAccessorWrapper.accessor
- ..setValue(stashKey, Value.withStringval(json))
- ..commit();
-
- return ReturnCode.ok;
- }
-}
-
-/// Utility class that wraps an instance of Stash's [StoreAccessor], as well as
-/// a function for closing it when [IntlSettingsController.close] is called.
-abstract class StoreAccessorWrapper {
- StoreAccessor get accessor;
-
- StoreAccessorCloser get close;
-}
-
-/// Implementers should close any FIDL channels associated with a
-/// [StoreAccessor].
-typedef StoreAccessorCloser = void Function();
-
-/// Implementers should provide a new instance of [StoreAccessorWrapper].
-typedef StoreAccessorWrapperProvider = StoreAccessorWrapper Function();
-
-class _StoreAccessorWrapperImpl extends StoreAccessorWrapper {
- final StoreAccessorProxy _storeAccessorProxy;
- final StoreAccessorCloser _closer;
-
- _StoreAccessorWrapperImpl(this._storeAccessorProxy, this._closer);
-
- @override
- StoreAccessor get accessor => _storeAccessorProxy;
-
- @override
- StoreAccessorCloser get close => _closer;
-}
-
-/// Default factory method for [StoreAccessorWrapper]. Connects to Stash and
-/// requests a [StoreAccessor].
-StoreAccessorWrapper createStoreAccessorWrapper() {
- ServiceProviderProxy environmentServices =
- StartupContext.fromStartupInfo().environmentServices;
-
- var storeProxy = StoreProxy();
- connectToService(environmentServices, storeProxy.ctrl);
-
- var storeAccessorProxy = StoreAccessorProxy();
-
- storeProxy
- ..identify(IntlSettingsController._stashStoreName)
- ..createAccessor(false, storeAccessorProxy.ctrl.request());
-
- connectToService(environmentServices, storeAccessorProxy.ctrl);
-
- void closer() {
- storeAccessorProxy.ctrl.close();
- storeProxy.ctrl.close();
- }
-
- return _StoreAccessorWrapperImpl(storeAccessorProxy, closer);
-}
diff --git a/lib/setui/settings/service/lib/src/network_controller.dart b/lib/setui/settings/service/lib/src/network_controller.dart
deleted file mode 100644
index 335ee37..0000000
--- a/lib/setui/settings/service/lib/src/network_controller.dart
+++ /dev/null
@@ -1,253 +0,0 @@
-// Copyright 2018 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 'dart:async';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-
-import 'setui_setting_controller.dart';
-
-// TODO: Implement and override applyMutation.
-class NetworkController extends SetUiSettingController {
- @override
- Future<void> close() async {
- // TODO: implement close
- }
-
- @override
- Future<void> initialize() async {
- // TODO: implement initialize
- }
-
- // TODO: implement value
- @override
- SettingsObject get value => null;
-}
-
-/// STOPSHIP(brycelee): re-enable once Migration is complete
-// /// How often to poll the wlan for wifi information.
-// const Duration _statusPeriod = Duration(seconds: 3);
-
-// /// How often to poll the wlan for available wifi networks.
-// const Duration _scanPeriod = Duration(seconds: 40);
-
-// const int _scanTimeout = 25;
-
-// const _connectionScanInterval = 3;
-
-// class NetworkController extends SetUiSettingController {
-// // List of APs that we obtained from wireless scanning.
-// // Periodically refreshed when there is no connected network.
-// List<wlan.Ap> _scannedAps = [];
-
-// /// This status is guaranteed to not be null as long as initialize is
-// /// called. Periodically refreshed.
-// wlan.WlanStatus _status;
-
-// Timer _updateTimer;
-// Timer _scanTimer;
-
-// wlan.WlanProxy _wlanProxy;
-
-// @override
-// Future<void> close() async {
-// _scanTimer?.cancel();
-// _updateTimer?.cancel();
-// _wlanProxy?.ctrl?.close();
-// _scannedAps = [];
-// _status = null;
-// }
-
-// @override
-// Future<void> initialize() async {
-// await initializeWithService(() async {
-// final proxy = wlan.WlanProxy();
-// connectToService(
-// StartupContext.fromStartupInfo().environmentServices, proxy.ctrl);
-// return proxy;
-// });
-// }
-
-// /// Initializes the controller with the given [wlan.WlanProxy].
-// ///
-// /// Needed to allow providing a fake proxy for testing.
-// @visibleForTesting
-// Future<void> initializeWithService(
-// Future<wlan.WlanProxy> proxyGetter()) async {
-// final Completer<bool> wlanCompleter = Completer();
-
-// _wlanProxy = await proxyGetter();
-
-// _updateTimer = Timer.periodic(_statusPeriod, (timer) {
-// _wlanProxy.status((status) {
-// if (_onStatusRefreshed(status)) {
-// notifyListeners();
-// }
-// });
-// });
-
-// _wlanProxy.status((status) {
-// _onStatusRefreshed(status);
-// wlanCompleter.complete(true);
-// });
-
-// /// Waits for all initial values and then returns false if any of the futures return false
-// return await wlanCompleter.future;
-// }
-
-// @override
-// Future<bool> setSettingValue(SettingsObject value) async {
-// assert(value.data.tag == SettingDataTag.wireless);
-
-// if (value.data.tag != SettingDataTag.wireless) {
-// return false;
-// }
-
-// final accessPoints = value.data.wireless?.accessPoints ?? [];
-
-// for (WirelessAccessPoint ap in accessPoints) {
-// if (_status.currentAp != null &&
-// ap.accessPointId == _accessPointId(_status.currentAp.ssid)) {
-// if (ap.status == ConnectionStatus.disconnected ||
-// ap.status == ConnectionStatus.disconnecting) {
-// await _disconnect();
-// }
-// } else {
-// if (ap.status == ConnectionStatus.connected ||
-// ap.status == ConnectionStatus.connecting) {
-// await _connect(ap.name,
-// ap.security == WirelessSecurity.secured ? ap.password : null);
-// }
-// }
-// }
-
-// return true;
-// }
-
-// @override
-// SettingsObject get value => _buildSettingsObject();
-
-// // Returns true if this caused a change in state.
-// bool _onStatusRefreshed(wlan.WlanStatus status) {
-// bool changed = false;
-
-// if (_status != status) {
-// _status = status;
-// changed = true;
-// }
-// if (status.state == wlan.State.associated) {
-// _scanTimer?.cancel();
-// _scannedAps = [];
-// } else {
-// if (_scanTimer == null || !_scanTimer.isActive) {
-// _scan();
-// _scanTimer = Timer.periodic(_scanPeriod, (timer) {
-// _scan();
-// });
-// }
-// }
-
-// return changed;
-// }
-
-// SettingsObject _buildSettingsObject() {
-// return SettingsObject(
-// settingType: SettingType.wireless,
-// data: SettingData.withWireless(_buildWirelessState()));
-// }
-
-// WirelessState _buildWirelessState() {
-// return WirelessState(
-// accessPoints: _status.currentAp != null
-// ? [_buildCurrentAccessPoint()]
-// : _scannedAps.map(_buildAccessPoint).toList());
-// }
-
-// WirelessAccessPoint _buildCurrentAccessPoint() =>
-// _buildAccessPoint(_status.currentAp, status: _getState(_status.state));
-
-// WirelessAccessPoint _buildAccessPoint(wlan.Ap accessPoint,
-// {ConnectionStatus status}) {
-// return WirelessAccessPoint(
-// accessPointId: _accessPointId(accessPoint.ssid),
-// security: accessPoint.isSecure
-// ? WirelessSecurity.secured
-// : WirelessSecurity.unsecured,
-// password: '',
-// rssi: accessPoint.rssiDbm,
-// status: status ?? ConnectionStatus.disconnected,
-// name: accessPoint.ssid);
-// }
-
-// void _scan() {
-// _wlanProxy.scan(const wlan.ScanRequest(timeout: _scanTimeout),
-// (wlan.ScanResult scanResult) {
-// _scannedAps = _dedupeAndRemoveIncompatible(scanResult);
-// notifyListeners();
-// });
-// }
-
-// Future<void> _disconnect() {
-// Completer completer = Completer();
-// _wlanProxy.disconnect((wlan.Error error) {
-// completer.complete();
-// });
-// return completer.future;
-// }
-
-// Future<bool> _connect(String ssid, [String password]) {
-// Completer<bool> completer = Completer();
-
-// final config = wlan.ConnectConfig(
-// ssid: ssid,
-// passPhrase: password ?? '',
-// scanInterval: _connectionScanInterval,
-// bssid: '');
-
-// _wlanProxy.connect(config, (result) {
-// completer.complete(result.code == wlan.ErrCode.ok);
-// });
-
-// return completer.future;
-// }
-// }
-
-// /// Remove duplicate and incompatible networks
-// List<wlan.Ap> _dedupeAndRemoveIncompatible(wlan.ScanResult scanResult) {
-// List<wlan.Ap> aps = <wlan.Ap>[];
-
-// if (scanResult.error.code == wlan.ErrCode.ok) {
-// // First sort APs by signal strength so when we de-dupe we drop the
-// // weakest ones
-// scanResult.aps.sort((wlan.Ap a, wlan.Ap b) => b.rssiDbm - a.rssiDbm);
-// Set<String> seenNames = Set<String>();
-
-// for (wlan.Ap ap in scanResult.aps) {
-// // Dedupe: if we've seen this ssid before, skip it.
-// if (!seenNames.contains(ap.ssid) && ap.isCompatible) {
-// aps.add(ap);
-// }
-// seenNames.add(ap.ssid);
-// }
-// }
-// return aps;
-// }
-
-// ConnectionStatus _getState(wlan.State state) {
-// switch (state) {
-// case wlan.State.associated:
-// return ConnectionStatus.connected;
-// case wlan.State.associating:
-// case wlan.State.joining:
-// case wlan.State.scanning:
-// case wlan.State.bss:
-// case wlan.State.querying:
-// case wlan.State.authenticating:
-// return ConnectionStatus.connecting;
-// default:
-// return ConnectionStatus.unknown;
-// }
-// }
-
-// int _accessPointId(String ssid) => ssid.hashCode;
diff --git a/lib/setui/settings/service/lib/src/setui_setting_controller.dart b/lib/setui/settings/service/lib/src/setui_setting_controller.dart
deleted file mode 100644
index 931eade..0000000
--- a/lib/setui/settings/service/lib/src/setui_setting_controller.dart
+++ /dev/null
@@ -1,90 +0,0 @@
-import 'dart:async';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:meta/meta.dart';
-
-/// Controller for a specific setting.
-///
-/// The service instantiates [SetUiSettingController]s mapped to [SettingType]s.
-abstract class SetUiSettingController {
- final List<SettingListenerProxy> listeners = [];
-
- @visibleForTesting
- bool active = false;
-
- Future<void> addListener(SettingListenerProxy listener) async {
- if (listeners.isEmpty) {
- await _initialize();
- }
- listeners.add(listener);
- listener.notify(_getValue());
- }
-
- Future<void> notifyListeners() async {
- listeners.removeWhere((listener) => !listener.ctrl.isBound);
- for (SettingListenerProxy listener in listeners) {
- listener.notify(_getValue());
- }
- if (listeners.isEmpty) {
- await _close();
- }
- }
-
- Future<ReturnCode> mutate(Mutation mutation,
- {MutationHandles handles}) async {
- if (listeners.isEmpty) {
- await _initialize();
- }
-
- if (!active)
- throw StateError(
- 'Attempted to mutate state with an uninitialized controller!');
-
- final result = await applyMutation(mutation, handles: handles);
-
- if (listeners.isEmpty) {
- await _close();
- }
-
- return result;
- }
-
- /// Subclasses should override this to make the changes requested
- /// by applyMutation, and return once complete.
- Future<ReturnCode> applyMutation(Mutation mutation,
- {MutationHandles handles}) async {
- return ReturnCode.unsupported;
- }
-
- /// Initializes the controller.
- ///
- /// notifyListeners shouldn't be called in this function, or close
- /// will be immediately called due to lack of listeners.
- /// Subclasses should override to apply mutations. By default, the operation
- /// is ignored and a failure result is returned.
- Future<void> initialize();
-
- // Close should stop listening to any underlying services.
- // [initialize] and [close] can both be called multiple times during the
- // controller's lifetime
- Future<void> close();
-
- Future<void> _initialize() async {
- await initialize();
- active = true;
- }
-
- Future<void> _close() async {
- await close();
- active = false;
- }
-
- SettingsObject _getValue() {
- if (!active)
- throw StateError(
- 'Attempted to retreive state from an uninitialized controller!');
- return value;
- }
-
- SettingsObject get value;
-}
diff --git a/lib/setui/settings/service/lib/src/timezone_controller.dart b/lib/setui/settings/service/lib/src/timezone_controller.dart
deleted file mode 100644
index a6af4ca..0000000
--- a/lib/setui/settings/service/lib/src/timezone_controller.dart
+++ /dev/null
@@ -1,86 +0,0 @@
-import 'dart:async';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:fidl_fuchsia_timezone/fidl.dart';
-import 'package:lib.app.dart/app.dart';
-
-import 'setui_setting_controller.dart';
-
-class TimeZoneController extends SetUiSettingController
- implements TimezoneWatcher {
- TimezoneProxy _timeZoneProxy;
-
- static const Map<String, TimeZone> _timeZones = {
- 'US/Pacific': TimeZone(
- id: 'US/Pacific',
- name: 'Pacific Standard Time',
- region: ['San Francisco', 'Seattle', 'Los Angeles']),
- 'US/Eastern': TimeZone(
- id: 'US/Eastern',
- name: 'Eastern Standard Time',
- region: ['Toronto', 'Detroit', 'New York']),
- 'Europe/Paris': TimeZone(
- id: 'Europe/Paris',
- name: 'Central European Standard Time',
- region: ['Paris']),
- 'Australia/Sydney': TimeZone(
- id: 'Australia/Sydney',
- name: 'Australian Eastern Standard Time',
- region: ['Sydney']),
- };
-
- String _currentTimeZoneId;
-
- @override
- Future<void> close() async {
- _timeZoneProxy.ctrl.close();
- _currentTimeZoneId = null;
- }
-
- @override
- Future<void> initialize() async {
- Completer<void> completer = Completer();
-
- _timeZoneProxy = TimezoneProxy();
- connectToService(StartupContext.fromStartupInfo().environmentServices,
- _timeZoneProxy.ctrl);
-
- _timeZoneProxy
- ..watch(TimezoneWatcherBinding().wrap(this))
- ..getTimezoneId((timezoneId) {
- _currentTimeZoneId = timezoneId;
- completer.complete();
- });
-
- return completer.future;
- }
-
- @override
- Future<ReturnCode> applyMutation(Mutation mutation,
- {MutationHandles handles}) async {
- assert(mutation.timeZoneMutationValue != null);
-
- final Completer<ReturnCode> completer = Completer<ReturnCode>();
- final currentTimeZone = mutation.timeZoneMutationValue.value.current;
- final newId = currentTimeZone != null ? currentTimeZone.id : 0;
-
- _timeZoneProxy.setTimezone(newId, (success) {
- completer.complete(ReturnCode.ok);
- });
-
- return completer.future;
- }
-
- @override
- SettingsObject get value => SettingsObject(
- settingType: SettingType.timeZone,
- data: SettingData.withTimeZoneValue(TimeZoneInfo(
- available: _timeZones.values.toList(),
- current: _timeZones[_currentTimeZoneId])));
-
- @override
- void onTimezoneOffsetChange(String timezoneId) {
- _currentTimeZoneId = timezoneId;
- notifyListeners();
- }
-}
diff --git a/lib/setui/settings/service/pubspec.yaml b/lib/setui/settings/service/pubspec.yaml
deleted file mode 100644
index a53fec4..0000000
--- a/lib/setui/settings/service/pubspec.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 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.
-
-# Dummy for Dart analysis server.
diff --git a/lib/setui/settings/service/test/intl/intl_settings_util_test.dart b/lib/setui/settings/service/test/intl/intl_settings_util_test.dart
deleted file mode 100644
index 6ca31ec..0000000
--- a/lib/setui/settings/service/test/intl/intl_settings_util_test.dart
+++ /dev/null
@@ -1,85 +0,0 @@
-// 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_setui/fidl.dart';
-import 'package:test/test.dart';
-import 'package:lib_setui_service/src/intl/intl_settings_util.dart' as util;
-
-// ignore_for_file: implementation_imports
-
-void main() {
- group('Intl settings util', () {
- test('setLocales() works', () {
- const before = IntlSettings(
- locales: ['en-US', 'es-MX', 'fr-FR', 'ru-RU'],
- hourCycle: HourCycle.h12,
- temperatureUnit: TemperatureUnit.celsius);
- const expected = IntlSettings(
- locales: ['en-US', 'fr-FR', 'ru-RU', 'es-MX'],
- hourCycle: HourCycle.h12,
- temperatureUnit: TemperatureUnit.celsius);
- expect(
- util.setLocales(before,
- LocalesMutation(locales: ['en-US', 'fr-FR', 'ru-RU', 'es-MX'])),
- equals(expected));
- });
-
- test('setHourCycle() works', () {
- const before = IntlSettings(
- locales: ['en-US', 'es-MX'],
- hourCycle: HourCycle.h12,
- temperatureUnit: TemperatureUnit.celsius);
- const expected = IntlSettings(
- locales: ['en-US', 'es-MX'],
- hourCycle: HourCycle.h23,
- temperatureUnit: TemperatureUnit.celsius);
- expect(
- util.setHourCycle(
- before, HourCycleMutation(hourCycle: HourCycle.h23)),
- equals(expected));
- });
-
- test('setTemperatureUnit() works', () {
- const before = IntlSettings(
- locales: ['en-US', 'es-MX'],
- hourCycle: HourCycle.h12,
- temperatureUnit: TemperatureUnit.celsius);
- const expected = IntlSettings(
- locales: ['en-US', 'es-MX'],
- hourCycle: HourCycle.h12,
- temperatureUnit: TemperatureUnit.fahrenheit);
- expect(
- util.setTemperatureUnit(
- before,
- TemperatureUnitMutation(
- temperatureUnit: TemperatureUnit.fahrenheit)),
- equals(expected));
- });
-
- test('toJson() works', () {
- const settings = IntlSettings(
- locales: ['en-US', 'es-MX'],
- hourCycle: HourCycle.h23,
- temperatureUnit: TemperatureUnit.fahrenheit);
- const expected =
- '{"locales":["en-US","es-MX"],"hour_cycle":"h23","temperature_unit":"fahrenheit"}';
- expect(util.toJson(settings), equals(expected));
- });
-
- test('fromJson() works', () {
- const json = '''
- {
- "locales": ["en-US", "es-MX"],
- "hour_cycle": "h23",
- "temperature_unit": "fahrenheit"
- }
- ''';
- const expected = IntlSettings(
- locales: ['en-US', 'es-MX'],
- hourCycle: HourCycle.h23,
- temperatureUnit: TemperatureUnit.fahrenheit);
- expect(util.fromJson(json), equals(expected));
- });
- });
-}
diff --git a/lib/setui/settings/service/test/intl_controller_test.dart b/lib/setui/settings/service/test/intl_controller_test.dart
deleted file mode 100644
index e727d87..0000000
--- a/lib/setui/settings/service/test/intl_controller_test.dart
+++ /dev/null
@@ -1,134 +0,0 @@
-// 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/src/interface.dart';
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:fidl_fuchsia_stash/fidl.dart';
-import 'package:lib_setui_service/src/intl_controller.dart';
-import 'package:lib_setui_service/src/intl/intl_settings_util.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-
-// ignore_for_file: implementation_imports
-
-const String _stashKey = IntlSettingsController.stashKey;
-
-void main() async {
- IntlSettingsController controller;
- _MockStoreAccessorWrapper storeAccessorWrapper;
- _FakeStoreAccessor storeAccessor;
-
- setUp(() {
- storeAccessor = _FakeStoreAccessor();
- storeAccessorWrapper = _MockStoreAccessorWrapper();
- when(storeAccessorWrapper.accessor).thenReturn(storeAccessor);
- StoreAccessorWrapper provider() => storeAccessorWrapper;
- controller = IntlSettingsController.withStashProvider(provider);
- });
-
- group('Intl controller', () {
- test('initialize() reads existing settings from Stash', () {
- const IntlSettings settings = IntlSettings(
- locales: ['en-US', 'es-MX'],
- hourCycle: HourCycle.h23,
- temperatureUnit: TemperatureUnit.fahrenheit);
-
- storeAccessor
- ..setValue(_stashKey, Value.withStringval(toJson(settings)))
- ..commit();
-
- controller.initialize();
- const SettingsObject expected = SettingsObject(
- settingType: SettingType.intl, data: SettingData.withIntl(settings));
- expect(expected, equals(controller.value));
- });
-
- test('applyMutation() writes to Stash', () {
- const IntlSettings initialSettings = IntlSettings(
- locales: ['en-US', 'es-MX'],
- hourCycle: HourCycle.h23,
- temperatureUnit: TemperatureUnit.fahrenheit);
-
- storeAccessor
- ..setValue(_stashKey, Value.withStringval(toJson(initialSettings)))
- ..commit();
-
- controller
- ..initialize()
- ..applyMutation(Mutation.withLocalesMutationValue(
- LocalesMutation(locales: ['en-US', 'es-MX', 'fr-FR'])));
-
- final expected = Value.withStringval(toJson(IntlSettings(
- locales: ['en-US', 'es-MX', 'fr-FR'],
- hourCycle: HourCycle.h23,
- temperatureUnit: TemperatureUnit.fahrenheit)));
- expect(storeAccessor.getValueDirectly(_stashKey), equals(expected));
- });
-
- test('close() closes Stash channels', () {
- bool isClosed = false;
- void stubClose() {
- isClosed = true;
- }
-
- when(storeAccessorWrapper.close).thenReturn(stubClose);
-
- controller
- ..initialize()
- ..close();
-
- expect(isClosed, isTrue);
- });
- });
-}
-
-/// Fake implementation of [StoreAccessor] (synchronous) that just uses
-/// in-memory maps.
-class _FakeStoreAccessor implements StoreAccessor {
- Map<String, Value> committedValues = {};
- Map<String, Value> pendingValues = {};
-
- @override
- void getValue(String key, void Function(Value val) callback) {
- callback(getValueDirectly(key));
- }
-
- /// Get a value without using a callback.
- Value getValueDirectly(String key) {
- return committedValues[key];
- }
-
- @override
- void setValue(String key, Value val) {
- pendingValues[key] = val;
- }
-
- @override
- void commit() {
- committedValues.addAll(pendingValues);
- pendingValues.clear();
- }
-
- @override
- void deletePrefix(String prefix) {
- throw UnimplementedError();
- }
-
- @override
- void deleteValue(String key) {
- throw UnimplementedError();
- }
-
- @override
- void getPrefix(String prefix, InterfaceRequest<GetIterator> it) {
- throw UnimplementedError();
- }
-
- @override
- void listPrefix(String prefix, InterfaceRequest<ListIterator> it) {
- throw UnimplementedError();
- }
-}
-
-class _MockStoreAccessorWrapper extends Mock implements StoreAccessorWrapper {}
diff --git a/lib/setui/settings/service/test/network_controller_test.dart b/lib/setui/settings/service/test/network_controller_test.dart
deleted file mode 100644
index 87b4d3c..0000000
--- a/lib/setui/settings/service/test/network_controller_test.dart
+++ /dev/null
@@ -1,187 +0,0 @@
-import 'dart:typed_data';
-
-import 'package:fidl/src/interface.dart';
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:fidl_fuchsia_wlan_mlme/fidl.dart' as mlme;
-import 'package:fidl_fuchsia_wlan_service/fidl.dart';
-import 'package:lib_setui_service/src/network_controller.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-
-// ignore_for_file: implementation_imports
-
-const String defaultValue = 'default';
-
-const String value1 = 'value1';
-
-void main() async {
- NetworkController controller;
- MockWlanProxy proxy;
- SettingListenerObject object;
-
- setUp(() async {
- proxy = MockWlanProxy();
- controller = NetworkController();
- object = SettingListenerObject();
-
- controller.listeners.add(object);
- controller.active = true;
- });
-
- group('Network controller', () {
- test('can get settings object', () async {
- when(proxy.status(any)).thenAnswer((invocation) {
- void Function(WlanStatus) callback =
- invocation.positionalArguments.first;
- callback(_status());
- });
-
- when(proxy.scan(any, any)).thenAnswer((invocation) {
- void Function(ScanResult) callback = invocation.positionalArguments[1];
- callback(
- ScanResult(error: Error(code: ErrCode.ok, description: ''), aps: [
- _buildAp('a', rssiDbm: 11),
- // Should be deduped by the other one
- _buildAp('a', rssiDbm: 5),
- // Shouldn't be included because incompatible
- _buildAp('b', isCompatible: false),
- _buildAp('c', isSecure: true)
- ]));
- });
-
- await controller.initializeWithService(() async => proxy);
-
- final settingsObject = controller.value;
-
- expect(settingsObject.settingType, SettingType.wireless);
- expect(settingsObject.data.wireless, isNotNull);
- expect(settingsObject.data.wireless.accessPoints.length, 2);
-
- int matchedPoints = 0;
- for (WirelessAccessPoint accessPoint
- in settingsObject.data.wireless.accessPoints) {
- if (accessPoint.name == 'a') {
- matchedPoints++;
- expect(accessPoint.rssi, 11);
- expect(accessPoint.security, WirelessSecurity.unsecured);
- } else if (accessPoint.name == 'c') {
- matchedPoints++;
- expect(accessPoint.rssi, 8);
- expect(accessPoint.security, WirelessSecurity.secured);
- }
- }
- expect(matchedPoints, 2);
- });
-
- test('will call service when disconnecting', () async {
- when(proxy.status(any)).thenAnswer((invocation) {
- void Function(WlanStatus) callback =
- invocation.positionalArguments.first;
- callback(WlanStatus(
- error: Error(code: ErrCode.ok, description: ''),
- state: State.associated,
- currentAp: _buildAp('a')));
- });
-
- await controller.initializeWithService(() async => proxy);
- final currentAp = controller.value.data.wireless.accessPoints.first;
-
- when(proxy.disconnect(any)).thenAnswer((invocation) {
- void Function(Error) callback = invocation.positionalArguments.first;
- callback(Error(code: ErrCode.ok, description: ''));
- });
-
- await controller.setSetting(SettingsObject(
- settingType: SettingType.wireless,
- data: SettingData.withWireless(WirelessState(accessPoints: [
- WirelessAccessPoint.clone(currentAp,
- status: ConnectionStatus.disconnected)
- ]))));
-
- verify(proxy.disconnect(any)).called(1);
- });
-
- test('will call service when connecting', () async {
- const password = 'password';
-
- when(proxy.status(any)).thenAnswer((invocation) {
- void Function(WlanStatus) callback =
- invocation.positionalArguments.first;
- callback(_status());
- });
-
- when(proxy.scan(any, any)).thenAnswer((invocation) {
- void Function(ScanResult) callback = invocation.positionalArguments[1];
- callback(ScanResult(
- error: Error(code: ErrCode.ok, description: ''),
- aps: [_buildAp('c', isSecure: true)]));
- });
-
- await controller.initializeWithService(() async => proxy);
- final currentAp = controller.value.data.wireless.accessPoints.first;
-
- when(proxy.connect(any, any)).thenAnswer((invocation) {
- final ConnectConfig connectConfig =
- invocation.positionalArguments.first;
-
- expect(connectConfig.passPhrase, password);
-
- void Function(Error) callback = invocation.positionalArguments[1];
- callback(Error(code: ErrCode.ok, description: ''));
- });
-
- await controller.setSetting(SettingsObject(
- settingType: SettingType.wireless,
- data: SettingData.withWireless(WirelessState(accessPoints: [
- WirelessAccessPoint.clone(currentAp,
- password: password, status: ConnectionStatus.connected)
- ]))));
-
- verify(proxy.connect(any, any)).called(1);
- });
- });
-
- tearDown(() {
- controller.close();
- });
-}
-
-WlanStatus _status() {
- return WlanStatus(
- error: Error(code: ErrCode.ok, description: ''), state: State.scanning);
-}
-
-Ap _buildAp(String ssid,
- {bool isCompatible = true, bool isSecure = false, int rssiDbm = 8}) =>
- Ap(
- ssid: ssid,
- rssiDbm: rssiDbm,
- chan: mlme.WlanChan(primary: 32, secondary80: 18, cbw: mlme.Cbw.cbw80),
- isCompatible: isCompatible,
- isSecure: isSecure,
- bssid: Uint8List.fromList([32, 0]),
- );
-
-class MockWlanProxy extends Mock implements WlanProxy {}
-
-class MockProxyController<T> extends Mock implements ProxyController<T> {}
-
-class SettingListenerObject implements SettingListenerProxy {
- SettingsObject object;
- MockProxyController<SettingListener> controller =
- MockProxyController<SettingListener>();
-
- SettingListenerObject() {
- when(controller.isBound).thenReturn(true);
- }
-
- @override
- ProxyController<SettingListener> get ctrl => controller;
-
- // This shouldn't be a setter since it overrides a different field.
- // ignore: use_setters_to_change_properties
- @override
- void notify(SettingsObject object) {
- this.object = object;
- }
-}
diff --git a/lib/setui/settings/testing/BUILD.gn b/lib/setui/settings/testing/BUILD.gn
deleted file mode 100644
index 30057a7..0000000
--- a/lib/setui/settings/testing/BUILD.gn
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2018 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("//build/dart/dart_library.gni")
-import("//topaz/runtime/dart/flutter_test.gni")
-
-dart_library("testing") {
- package_name = "lib_setui_settings_testing"
-
- sources = [
- "mock_setting_adapter.dart",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.setui",
- "//topaz/lib/setui/settings/client:client",
- "//topaz/lib/setui/settings/common:common",
- ]
-}
-
-flutter_test("lib_setui_settings_testing_test") {
- sources = [
- "mock_setting_adapter_test.dart",
- ]
-
- deps = [
- ":testing",
- "//sdk/fidl/fuchsia.setui",
- "//third_party/dart-pkg/git/flutter/packages/flutter_test",
- "//third_party/dart-pkg/pub/test",
- "//topaz/lib/setui/settings/common:common",
- ]
-}
diff --git a/lib/setui/settings/testing/analysis_options.yaml b/lib/setui/settings/testing/analysis_options.yaml
deleted file mode 100644
index 49a21d7..0000000
--- a/lib/setui/settings/testing/analysis_options.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2018 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.
-
-include: ../analysis_options.yaml
-
diff --git a/lib/setui/settings/testing/lib/mock_setting_adapter.dart b/lib/setui/settings/testing/lib/mock_setting_adapter.dart
deleted file mode 100644
index 8e5aa24..0000000
--- a/lib/setui/settings/testing/lib/mock_setting_adapter.dart
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright 2018 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 'dart:async';
-
-import 'package:fidl_fuchsia_setui/fidl.dart';
-import 'package:lib_setui_settings_common/setting_adapter.dart';
-import 'package:lib_setui_settings_common/setting_source.dart';
-
-typedef LogAction = void Function();
-typedef LogExecutor = void Function(Duration delay, LogAction action);
-
-/// An adapter that can be preconfigured to return set values.
-class MockSettingAdapter implements SettingAdapter {
- final Map<SettingType, SettingSource> _sources = {};
- final Map<int, Completer<UpdateResponse>> _activeResponses = {};
- final Map<int, Completer<MutationResponse>> _activeMutationResponses = {};
- final List<AdapterLog> logs;
- final LogExecutor executor;
-
- /// Default constructor to execute provided [AdapterLog]s. A [LogExecutor] may
- /// be provided to override the default behavior of executing server logs
- /// based on their time relationship with the closest user action keyframe.
- MockSettingAdapter(this.logs, {this.executor = _logExecute});
-
- @override
- SettingSource<T> fetch<T>(SettingType settingType) {
- if (!_sources.containsKey(settingType)) {
- _sources[settingType] = SettingSource<T>();
- }
-
- // Immediately unwind to the matching fetch
- _unwindTo((AdapterLog log) =>
- log.type == AdapterLogType.fetch && log.fetchLog.type == settingType);
-
- if (logs.isNotEmpty) {
- // Unwind in relation to the found fetch log.
- final AdapterLog log = logs.removeAt(0);
- _unwindTo((AdapterLog log) => log.fromClient, keyFrame: log.time);
- }
- return _sources[settingType];
- }
-
- @override
- Future<UpdateResponse> update(SettingsObject updatedSetting) {
- final Completer<UpdateResponse> completer = Completer<UpdateResponse>();
-
- // Unwind to the matching update log.
- _unwindTo((AdapterLog log) {
- return log.type == AdapterLogType.update &&
- log.updateLog.settings.settingType == updatedSetting.settingType;
- });
-
- if (logs.isEmpty) {
- completer.complete(null);
- } else {
- final AdapterLog log = logs.removeAt(0);
-
- _activeResponses[log.updateLog.id] = completer;
-
- // Unwind to the next client log.
- _unwindTo((AdapterLog log) => log.fromClient, keyFrame: log.time);
- }
- return completer.future;
- }
-
- @override
- Future<MutationResponse> mutate(SettingType settingType, Mutation mutation,
- {MutationHandles handles}) {
- final Completer<MutationResponse> completer = Completer<MutationResponse>();
-
- // Unwind to the matching update log.
- _unwindTo((AdapterLog log) {
- return log.type == AdapterLogType.mutation &&
- log.mutationLog.settingType == settingType;
- });
-
- if (logs.isEmpty) {
- completer.complete(null);
- } else {
- final AdapterLog log = logs.removeAt(0);
-
- _activeMutationResponses[log.mutationLog.id] = completer;
-
- // Unwind to the next client log.
- _unwindTo((AdapterLog log) => log.fromClient, keyFrame: log.time);
- }
- return completer.future;
- }
-
- /// Replays logs up to the log which matches the conditions provided by the
- /// input match function. The keyframe provides a time reference which events
- /// will be temporally executed against.
- void _unwindTo(bool match(AdapterLog log), {DateTime keyFrame}) {
- while (logs.isNotEmpty && !match(logs.first)) {
- _processLog(keyFrame, logs.removeAt(0));
- }
- }
-
- void _processLog(DateTime keyFrame, AdapterLog log) {
- LogAction action;
-
- switch (log.type) {
- case AdapterLogType.response:
- action = () {
- final Completer completer =
- _activeResponses[log.responseLog.updateId];
- if (completer == null) {
- return;
- }
-
- completer.complete(log.responseLog.response);
- };
- break;
- case AdapterLogType.mutationResponse:
- action = () {
- final Completer completer =
- _activeMutationResponses[log.mutationResponseLog.mutationId];
- if (completer == null) {
- return;
- }
-
- completer.complete(log.mutationResponseLog.response);
- };
- break;
- case AdapterLogType.setting:
- action = () => _sources[log.settingLog.settings.settingType]
- .notify(log.settingLog.settings);
- break;
- }
-
- if (action != null) {
- executor(keyFrame != null ? log.time.difference(keyFrame) : Duration.zero,
- action);
- }
- }
-
- /// Default playback mechanism, executing action after specified delay.
- static void _logExecute(Duration delay, LogAction action) {
- Future.delayed(delay, action);
- }
-}
diff --git a/lib/setui/settings/testing/pubspec.yaml b/lib/setui/settings/testing/pubspec.yaml
deleted file mode 100644
index fd4bc0e..0000000
--- a/lib/setui/settings/testing/pubspec.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 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.
-
-name: settings_testing
diff --git a/lib/setui/settings/testing/test/mock_setting_adapter_test.dart b/lib/setui/settings/testing/test/mock_setting_adapter_test.dart
deleted file mode 100644
index 2e5520c..0000000
--- a/lib/setui/settings/testing/test/mock_setting_adapter_test.dart
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2018 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_setui/fidl.dart';
-import 'package:lib_setui_settings_common/setting_adapter.dart';
-import 'package:lib_setui_settings_common/setting_source.dart';
-import 'package:lib_setui_settings_testing/mock_setting_adapter.dart';
-import 'package:test/test.dart';
-
-void main() {
- /// The following test ensures events are executed and held according to the
- /// replay timeline. In the following scenario, we should see the following:
- /// 1. client fetch of time zone
- /// 2. time zone update from server
- /// 3. client fetch of connectivity
- /// 4. time zone update from server
- /// 5. connectivity update from server.
- test('test_log_test', () async {
- final List<AdapterLog> logs = [];
-
- final DateTime epoch = DateTime.now();
-
- final TimeZone tz1 = TimeZone(region: [], id: 'tz1', name: 'timezone1');
- final TimeZone tz2 = TimeZone(region: [], id: 'tz2', name: 'timezone2');
-
- final SettingsObject tzSettings1 = SettingsObject(
- settingType: SettingType.timeZone,
- data: SettingData.withTimeZoneValue(
- TimeZoneInfo(available: [tz1], current: null)));
-
- final SettingsObject tzSettings2 = SettingsObject(
- settingType: SettingType.timeZone,
- data: SettingData.withTimeZoneValue(
- TimeZoneInfo(available: [tz1, tz2], current: tz1)));
-
- final SettingsObject connectivitySettings1 = SettingsObject(
- settingType: SettingType.connectivity,
- data: SettingData.withConnectivity(
- ConnectedState(reachability: Reachability.wan)));
-
- logs
- ..add(AdapterLog.withFetch(
- epoch.add(Duration(seconds: 1)), FetchLog(SettingType.timeZone)))
- ..add(AdapterLog.withSetting(
- epoch.add(Duration(seconds: 2)), SettingLog(tzSettings1)))
- ..add(AdapterLog.withFetch(
- epoch.add(Duration(seconds: 3)), FetchLog(SettingType.connectivity)))
- ..add(AdapterLog.withSetting(
- epoch.add(Duration(seconds: 4)), SettingLog(tzSettings2)))
- ..add(AdapterLog.withSetting(
- epoch.add(Duration(seconds: 5)), SettingLog(connectivitySettings1)));
-
- TestExecutor executor = TestExecutor();
-
- final MockSettingAdapter adapter =
- MockSettingAdapter(logs, executor: executor.capture);
-
- // 1. Fetch time zone
- final SettingSource<TimeZoneInfo> tzSource =
- adapter.fetch(SettingType.timeZone);
-
- expect(executor.actions.length, 1);
-
- // 2. Time zone returned from server
- executor.playback();
- expect(tzSource.state, tzSettings1.data.timeZoneValue);
-
- // 3. Fetch connectivity
- final SettingSource<ConnectedState> connectedSource =
- adapter.fetch(SettingType.connectivity);
-
- expect(executor.actions.length, 2);
-
- // 4. Time zone returned from server
- executor.playback();
- expect(tzSource.state, tzSettings2.data.timeZoneValue);
-
- // 5. Connectivity returned from server
- executor.playback();
- expect(connectedSource.state, connectivitySettings1.data.connectivity);
- });
-}
-
-class TestExecutor {
- List<LogAction> actions = [];
-
- void capture(Duration delay, LogAction action) {
- actions.add(action);
- }
-
- void playback() {
- if (actions.isEmpty) {
- return;
- }
-
- actions.removeAt(0)();
- }
-}
diff --git a/packages/tests/BUILD.gn b/packages/tests/BUILD.gn
index 6c8a36b..4703d2b 100644
--- a/packages/tests/BUILD.gn
+++ b/packages/tests/BUILD.gn
@@ -27,10 +27,6 @@
"//topaz/lib/keyboard/flutter:keyboard_test($host_toolchain)",
"//topaz/lib/setui/common:lib_setui_common_test($host_toolchain)",
"//topaz/lib/setui/flutter:lib_setui_flutter_test($host_toolchain)",
- "//topaz/lib/setui/settings/client:lib_setui_settings_client_test($host_toolchain)",
- "//topaz/lib/setui/settings/common:lib_setui_settings_common_test($host_toolchain)",
- "//topaz/lib/setui/settings/service:lib_setui_service_test($host_toolchain)",
- "//topaz/lib/setui/settings/testing:lib_setui_settings_testing_test($host_toolchain)",
"//topaz/lib/tiler:tiler_unittests($host_toolchain)",
"//topaz/public/dart/composition_delegate:composition_delegate_tests($host_toolchain)",
"//topaz/public/dart/fuchsia_inspect:fuchsia_inspect_package_unittests($host_toolchain)",
diff --git a/packages/tests/dart_unittests b/packages/tests/dart_unittests
index c5efb47..4bf285f 100644
--- a/packages/tests/dart_unittests
+++ b/packages/tests/dart_unittests
@@ -5,10 +5,6 @@
"//topaz/lib/keyboard/flutter:keyboard_test",
"//topaz/lib/setui/common:lib_setui_common_test",
"//topaz/lib/setui/flutter:lib_setui_flutter_test",
- "//topaz/lib/setui/settings/client:lib_setui_settings_client_test",
- "//topaz/lib/setui/settings/common:lib_setui_settings_common_test",
- "//topaz/lib/setui/settings/service:lib_setui_service_test",
- "//topaz/lib/setui/settings/testing:lib_setui_settings_testing_test",
"//topaz/public/dart/composition_delegate:composition_delegate_tests",
"//topaz/public/dart/fuchsia_inspect:fuchsia_inspect_package_unittests",
"//topaz/public/dart/fuchsia_logger:fuchsia_logger_package_unittests",