[story shell] rename lib from 'mondrian' to 'composition_delegate'
Rename Composer to CompositionDelegate
Move code to /dart from /lib
The CompositionDelegate is designed to be used by Presenters to
determine composition given a model of the Story.
test: build using --available topaz/packages/default and then
fx run-host-tests composition_delegate_tests
Change-Id: I26b04c90f9941530b573bd36bfffff2dfaf0ceca
diff --git a/packages/tests/BUILD.gn b/packages/tests/BUILD.gn
index 870322d..4d39c45 100644
--- a/packages/tests/BUILD.gn
+++ b/packages/tests/BUILD.gn
@@ -30,6 +30,7 @@
"//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/public/dart/composition_delegate:composition_delegate_tests($host_toolchain)",
"//topaz/public/dart/fuchsia_inspect:fuchsia_inspect_package_unittests($host_toolchain)",
"//topaz/public/dart/fuchsia_logger:fuchsia_logger_package_unittests($host_toolchain)",
"//topaz/public/dart/fuchsia_modular:fuchsia_modular_package_unittests($host_toolchain)",
@@ -39,7 +40,6 @@
"//topaz/public/dart/widgets:dart_widget_tests($host_toolchain)",
"//topaz/public/lib/app/dart:dart_app_tests($host_toolchain)",
"//topaz/public/lib/display/flutter:display_test($host_toolchain)",
- "//topaz/public/lib/mondrian/dart:mondrian_lib_tests($host_toolchain)",
"//topaz/public/lib/schemas/dart:dart_schema_tests($host_toolchain)",
"//topaz/public/lib/testing/app_driver/dart:fake_module_driver_test($host_toolchain)",
"//topaz/shell/mondrian_story_shell:mondrian_story_shell_tests($host_toolchain)",
diff --git a/packages/tests/dart_unittests b/packages/tests/dart_unittests
new file mode 100644
index 0000000..c9547c5
--- /dev/null
+++ b/packages/tests/dart_unittests
@@ -0,0 +1,26 @@
+{
+ "host_tests" : [
+ "//topaz/bin/dart_fidl_json/test:dart_fidl_json_test",
+ "//topaz/examples/test/flutter_widget_test",
+ "//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",
+ "//topaz/public/dart/fuchsia_modular:fuchsia_modular_package_unittests",
+ "//topaz/public/dart/fuchsia_services:fuchsia_services_package_unittests",
+ "//topaz/public/dart/fuchsia_scenic_flutter:fuchsia_scenic_flutter_unittests",
+ "//topaz/public/dart/sledge:dart_sledge_tests",
+ "//topaz/public/dart/widgets:dart_widget_tests",
+ "//topaz/public/lib/app/dart:dart_app_tests",
+ "//topaz/public/lib/display/flutter:display_test",
+ "//topaz/public/lib/schemas/dart:dart_schema_tests",
+ "//topaz/public/lib/testing/app_driver/dart:fake_module_driver_test",
+ "//topaz/shell/mondrian_story_shell:mondrian_story_shell_tests"
+ ]
+}
diff --git a/public/dart/composition_delegate/BUILD.gn b/public/dart/composition_delegate/BUILD.gn
new file mode 100644
index 0000000..e7dd0a9
--- /dev/null
+++ b/public/dart/composition_delegate/BUILD.gn
@@ -0,0 +1,36 @@
+# 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("//build/dart/test.gni")
+import("//build/dart/dart_library.gni")
+
+dart_library("dart") {
+ package_name = "composition_delegate.dart"
+
+ sdk_category = "partner"
+ sources = [
+ "composition_delegate.dart",
+ ]
+
+ deps = [
+ "//third_party/dart-pkg/pub/logging",
+ "//third_party/dart-pkg/pub/meta",
+ "//third_party/dart-pkg/pub/quiver"
+ ]
+}
+
+dart_test("composition_delegate_tests") {
+ sources = [
+ "encode_decode_test.dart",
+ "internal/surface_node_test.dart",
+ "internal/surface_tree_test.dart",
+ "layout_test.dart",
+ ]
+
+ deps = [
+ ":dart",
+ "//third_party/dart-pkg/pub/logging",
+ "//third_party/dart-pkg/pub/test",
+ ]
+}
\ No newline at end of file
diff --git a/public/lib/mondrian/dart/analysis_options.yaml b/public/dart/composition_delegate/analysis_options.yaml
similarity index 79%
rename from public/lib/mondrian/dart/analysis_options.yaml
rename to public/dart/composition_delegate/analysis_options.yaml
index ab9fb14..bebf512 100644
--- a/public/lib/mondrian/dart/analysis_options.yaml
+++ b/public/dart/composition_delegate/analysis_options.yaml
@@ -2,4 +2,4 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-include: ../../../analysis_options.yaml
+include: ../../analysis_options.yaml
diff --git a/public/lib/mondrian/dart/lib/mondrian.dart b/public/dart/composition_delegate/lib/composition_delegate.dart
similarity index 75%
rename from public/lib/mondrian/dart/lib/mondrian.dart
rename to public/dart/composition_delegate/lib/composition_delegate.dart
index 05386db..1797e27 100644
--- a/public/lib/mondrian/dart/lib/mondrian.dart
+++ b/public/dart/composition_delegate/lib/composition_delegate.dart
@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-export 'src/composer.dart';
+export 'src/composition_delegate/composition_delegate.dart';
export 'src/layout/layout_context.dart';
export 'src/layout/layout_types.dart';
export 'src/surface/surface.dart';
export 'src/surface/surface_relation.dart';
-export 'src/tree/surface_node.dart';
-export 'src/tree/surface_tree.dart';
-
diff --git a/public/lib/mondrian/dart/lib/src/composer.dart b/public/dart/composition_delegate/lib/src/composition_delegate/composition_delegate.dart
similarity index 93%
rename from public/lib/mondrian/dart/lib/src/composer.dart
rename to public/dart/composition_delegate/lib/src/composition_delegate/composition_delegate.dart
index 1686fb8..02e198e 100644
--- a/public/lib/mondrian/dart/lib/src/composer.dart
+++ b/public/dart/composition_delegate/lib/src/composition_delegate/composition_delegate.dart
@@ -5,15 +5,15 @@
import 'dart:collection';
import 'package:meta/meta.dart';
-import 'layout/layout_context.dart';
-import 'layout/layout_types.dart';
-import 'surface/surface.dart';
-import 'tree/surface_tree.dart';
+import '../internal/tree/_surface_tree.dart';
+import '../layout/layout_context.dart';
+import '../layout/layout_types.dart';
+import '../surface/surface.dart';
-/// The Composer maintains the model of surfaces participating in an experience
-/// and their relationships. Using context such as viewport area, surface
-/// metadata, etc., it determines a layout given a 'focused' surface.
-class Composer {
+/// The CompositionDelegate maintains the model of surfaces participating in an
+/// experience and their relationships. Using context such as viewport area,
+/// surface metadata, etc., it determines a layout given a 'focused' surface.
+class CompositionDelegate {
/// The set of surfaces that are currently marked as 'hidden' in the
/// experience - they are still present in the experience, but they will not
/// be laid out until they have focusSurface() called on them.
@@ -37,7 +37,7 @@
const LayoutContext(size: const Size(1280, 800));
/// Constructor
- Composer({
+ CompositionDelegate({
this.layoutContext = defaultContext,
}) : _hiddenSurfaces = <String>{},
_surfaceTree = new SurfaceTree();
diff --git a/public/lib/mondrian/dart/lib/src/tree/surface_node.dart b/public/dart/composition_delegate/lib/src/internal/tree/_surface_node.dart
similarity index 97%
rename from public/lib/mondrian/dart/lib/src/tree/surface_node.dart
rename to public/dart/composition_delegate/lib/src/internal/tree/_surface_node.dart
index 9b13b43..4f204d2 100644
--- a/public/lib/mondrian/dart/lib/src/tree/surface_node.dart
+++ b/public/dart/composition_delegate/lib/src/internal/tree/_surface_node.dart
@@ -3,8 +3,8 @@
// found in the LICENSE file.
import 'package:meta/meta.dart';
-import '../surface/surface.dart';
-import '../surface/surface_relation.dart';
+import '../../surface/surface.dart';
+import '../../surface/surface_relation.dart';
/// Simple mutable SurfaceNode data structure
class SurfaceNode extends Iterable<SurfaceNode> {
diff --git a/public/lib/mondrian/dart/lib/src/tree/surface_tree.dart b/public/dart/composition_delegate/lib/src/internal/tree/_surface_tree.dart
similarity index 92%
rename from public/lib/mondrian/dart/lib/src/tree/surface_tree.dart
rename to public/dart/composition_delegate/lib/src/internal/tree/_surface_tree.dart
index c90eb83..3b3a9c3 100644
--- a/public/lib/mondrian/dart/lib/src/tree/surface_tree.dart
+++ b/public/dart/composition_delegate/lib/src/internal/tree/_surface_tree.dart
@@ -1,18 +1,18 @@
// 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:fuchsia_logger/logger.dart';
+import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
-import '../surface/surface.dart';
-import '../surface/surface_relation.dart';
-import './surface_node.dart';
+import '../../surface/surface.dart';
+import '../../surface/surface_relation.dart';
+import './_surface_node.dart';
+
+/// A logger for Surface Tree warnings
+Logger log = Logger.root;
/// A SurfaceTree of SurfaceNodes
class SurfaceTree extends Iterable<Surface> {
/// Construct [SurfaceTree]
- SurfaceTree() {
- setupLogger(name: 'libMondrian', level: Level.FINE);
- }
/// The root of the SurfaceTree. SurfaceNodes added to the Tree without
/// specifying parents are added to the root.
@@ -29,11 +29,10 @@
}) {
// If the Surface is already in the Tree, return;
if (_nodeMap.containsKey(node.surface.surfaceId)) {
- log
- ..warning(
- 'Surface with id "${node.surface.surfaceId}" already in tree.')
- ..warning('Use update() to modify existing Surfaces.'
- 'Surface will not be not re-added.');
+ log.warning(
+ 'Surface with id "${node.surface.surfaceId}" already in tree. '
+ 'Use update() to modify existing Surfaces. '
+ 'Surface will not be not re-added.');
return;
}
// If an invalid parent was specified throw an error
diff --git a/public/lib/mondrian/dart/lib/src/layout/layout_context.dart b/public/dart/composition_delegate/lib/src/layout/layout_context.dart
similarity index 81%
rename from public/lib/mondrian/dart/lib/src/layout/layout_context.dart
rename to public/dart/composition_delegate/lib/src/layout/layout_context.dart
index 27c5448..3b0e17a 100644
--- a/public/lib/mondrian/dart/lib/src/layout/layout_context.dart
+++ b/public/dart/composition_delegate/lib/src/layout/layout_context.dart
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-/// The context in which the Composer determines layout
+/// The context in which the CompositionDelegate determines layout
class LayoutContext {
- /// The size of the viewport the Composer can use
+ /// The size of the viewport the CompositionDelegate can use
final Size size;
/// Constructor
diff --git a/public/lib/mondrian/dart/lib/src/layout/layout_types.dart b/public/dart/composition_delegate/lib/src/layout/layout_types.dart
similarity index 100%
rename from public/lib/mondrian/dart/lib/src/layout/layout_types.dart
rename to public/dart/composition_delegate/lib/src/layout/layout_types.dart
diff --git a/public/lib/mondrian/dart/lib/src/surface/surface.dart b/public/dart/composition_delegate/lib/src/surface/surface.dart
similarity index 100%
rename from public/lib/mondrian/dart/lib/src/surface/surface.dart
rename to public/dart/composition_delegate/lib/src/surface/surface.dart
diff --git a/public/lib/mondrian/dart/lib/src/surface/surface_relation.dart b/public/dart/composition_delegate/lib/src/surface/surface_relation.dart
similarity index 100%
rename from public/lib/mondrian/dart/lib/src/surface/surface_relation.dart
rename to public/dart/composition_delegate/lib/src/surface/surface_relation.dart
diff --git a/public/lib/mondrian/dart/pubspec.yaml b/public/dart/composition_delegate/pubspec.yaml
similarity index 100%
rename from public/lib/mondrian/dart/pubspec.yaml
rename to public/dart/composition_delegate/pubspec.yaml
diff --git a/public/lib/mondrian/dart/test/encode_decode_test.dart b/public/dart/composition_delegate/test/encode_decode_test.dart
similarity index 91%
rename from public/lib/mondrian/dart/test/encode_decode_test.dart
rename to public/dart/composition_delegate/test/encode_decode_test.dart
index 94eb8e5..707ee78 100644
--- a/public/lib/mondrian/dart/test/encode_decode_test.dart
+++ b/public/dart/composition_delegate/test/encode_decode_test.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:lib.mondrian.dart/mondrian.dart';
+import 'package:composition_delegate.dart/composition_delegate.dart';
import 'package:test/test.dart';
void main() {
diff --git a/public/lib/mondrian/dart/test/surface_node_test.dart b/public/dart/composition_delegate/test/internal/surface_node_test.dart
similarity index 94%
rename from public/lib/mondrian/dart/test/surface_node_test.dart
rename to public/dart/composition_delegate/test/internal/surface_node_test.dart
index 269eafc..ede4072 100644
--- a/public/lib/mondrian/dart/test/surface_node_test.dart
+++ b/public/dart/composition_delegate/test/internal/surface_node_test.dart
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:lib.mondrian.dart/mondrian.dart';
+// ignore_for_file: implementation_imports
+import 'package:composition_delegate.dart/composition_delegate.dart';
+import 'package:composition_delegate.dart/src/internal/tree/_surface_node.dart';
import 'package:test/test.dart';
// import 'package:lib.app.dart/logging.dart';
diff --git a/public/lib/mondrian/dart/test/surface_tree_test.dart b/public/dart/composition_delegate/test/internal/surface_tree_test.dart
similarity index 94%
rename from public/lib/mondrian/dart/test/surface_tree_test.dart
rename to public/dart/composition_delegate/test/internal/surface_tree_test.dart
index c2c71e7..dee43d6 100644
--- a/public/lib/mondrian/dart/test/surface_tree_test.dart
+++ b/public/dart/composition_delegate/test/internal/surface_tree_test.dart
@@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:lib.mondrian.dart/mondrian.dart';
+// ignore_for_file: implementation_imports
+import 'package:composition_delegate.dart/composition_delegate.dart';
+import 'package:composition_delegate.dart/src/internal/tree/_surface_node.dart';
+import 'package:composition_delegate.dart/src/internal/tree/_surface_tree.dart';
import 'package:test/test.dart';
void main() {
diff --git a/public/lib/mondrian/dart/test/layout_test.dart b/public/dart/composition_delegate/test/layout_test.dart
similarity index 77%
rename from public/lib/mondrian/dart/test/layout_test.dart
rename to public/dart/composition_delegate/test/layout_test.dart
index e6a2d29..78d4083 100644
--- a/public/lib/mondrian/dart/test/layout_test.dart
+++ b/public/dart/composition_delegate/test/layout_test.dart
@@ -2,41 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:lib.mondrian.dart/mondrian.dart';
+import 'package:composition_delegate.dart/composition_delegate.dart';
import 'package:test/test.dart';
void main() {
- Composer setupComposer() {
- Composer composer =
- new Composer(layoutContext: new LayoutContext(size: Size(1280, 800)));
- return composer;
+ CompositionDelegate setupCompositionDelegate() {
+ CompositionDelegate compDelegate = new CompositionDelegate(
+ layoutContext: new LayoutContext(size: Size(1280, 800)));
+ return compDelegate;
}
group(
'Test layout determination',
() {
test('For no Surfaces is empty', () {
- Composer composer = setupComposer();
- expect(composer.getLayout(), equals([]));
+ CompositionDelegate compDelegate = setupCompositionDelegate();
+ expect(compDelegate.getLayout(), equals([]));
});
test('For one Surface is full screen', () {
// expect a List, with one Layer, with one SurfaceLayout
- Composer composer = setupComposer();
+ CompositionDelegate compDelegate = setupCompositionDelegate();
List<Layer> expectedLayout = <Layer>[
Layer(
element: SurfaceLayout(
x: 0.0, y: 0.0, w: 1280.0, h: 800.0, surfaceId: 'first'))
];
- composer
+ compDelegate
..addSurface(surface: Surface(surfaceId: 'first'))
..focusSurface(surfaceId: 'first');
- expect(composer.getLayout(), equals(expectedLayout));
+ expect(compDelegate.getLayout(), equals(expectedLayout));
});
test('For two Surfaces with no relationship is stacked', () {
- Composer composer = setupComposer();
+ CompositionDelegate compDelegate = setupCompositionDelegate();
Layer expectedUpper = Layer(
element: SurfaceLayout(
@@ -48,16 +48,16 @@
List<Layer> expectedLayout = [expectedLower, expectedUpper];
// This test relies on the surface being focused in the correct order as the focus list is
// maintained separaretly from what has been added to the tree.
- composer
+ compDelegate
..addSurface(surface: Surface(surfaceId: 'first'))
..focusSurface(surfaceId: 'first')
..addSurface(surface: Surface(surfaceId: 'second'))
..focusSurface(surfaceId: 'second');
- expect(composer.getLayout(), equals(expectedLayout));
+ expect(compDelegate.getLayout(), equals(expectedLayout));
});
test('For two related Surfaces is a 50/50 split', () {
- Composer composer = setupComposer();
+ CompositionDelegate compDelegate = setupCompositionDelegate();
List<SurfaceLayout> surfaces = [
SurfaceLayout(x: 0.0, y: 0.0, w: 640.0, h: 800.0, surfaceId: 'first'),
SurfaceLayout(
@@ -65,7 +65,7 @@
];
Layer expectedLayout = Layer.fromList(elements: surfaces);
- composer
+ compDelegate
..addSurface(surface: Surface(surfaceId: 'first'))
..addSurface(
surface: Surface(
@@ -74,13 +74,13 @@
),
parentId: 'first')
..focusSurface(surfaceId: 'second');
- expect(composer.getLayout(), equals([expectedLayout]));
+ expect(compDelegate.getLayout(), equals([expectedLayout]));
});
test(
'For four Surfaces, 3 children with the same parent, is split into quarters vertically',
() {
- Composer composer = setupComposer();
+ CompositionDelegate compDelegate = setupCompositionDelegate();
List<SurfaceLayout> surfaces = [
SurfaceLayout(x: 0.0, y: 0.0, w: 320.0, h: 800.0, surfaceId: 'first'),
SurfaceLayout(
@@ -92,7 +92,7 @@
];
Layer expectedLayout = Layer.fromList(elements: surfaces);
- composer
+ compDelegate
..addSurface(surface: Surface(surfaceId: 'first'))
..addSurface(
surface: Surface(
@@ -113,7 +113,7 @@
),
parentId: 'first')
..focusSurface(surfaceId: 'fourth');
- expect(composer.getLayout(), equals([expectedLayout]));
+ expect(compDelegate.getLayout(), equals([expectedLayout]));
});
},
);
diff --git a/public/lib/mondrian/dart/BUILD.gn b/public/lib/mondrian/dart/BUILD.gn
deleted file mode 100644
index 0391bd3..0000000
--- a/public/lib/mondrian/dart/BUILD.gn
+++ /dev/null
@@ -1,43 +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("//build/dart/dart_library.gni")
-import("//topaz/runtime/dart/flutter_test.gni")
-
-dart_library("dart") {
- package_name = "lib.mondrian.dart"
-
- sdk_category = "partner"
- sources = [
- "mondrian.dart",
- "src/composer.dart",
- "src/layout/layout_context.dart",
- "src/layout/layout_types.dart",
- "src/tree/surface_node.dart",
- "src/tree/surface_tree.dart",
- "src/surface/surface_relation.dart",
- "src/surface/surface.dart",
- ]
-
- deps = [
- "//third_party/dart-pkg/pub/meta",
- "//topaz/public/dart/fuchsia_logger"
- ]
-}
-
-flutter_test("mondrian_lib_tests") {
- sources = [
- "encode_decode_test.dart",
- "layout_test.dart",
- "surface_node_test.dart",
- "surface_tree_test.dart",
- ]
-
- deps = [
- ":dart",
- "//third_party/dart-pkg/pub/logging",
- "//third_party/dart-pkg/pub/test",
- "//topaz/public/lib/mondrian/dart",
- ]
-}