diff --git a/samples-dev/samples-dev.status b/samples-dev/samples-dev.status deleted file mode 100644 index 66ee67b442e..00000000000 --- a/samples-dev/samples-dev.status +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -# for details. All rights reserved. Use of this source code is governed by a -# BSD-style license that can be found in the LICENSE file. - -[ $compiler == dart2analyzer ] -swarm/test/swarm_test: StaticWarning -swarm/test/swarm_ui_lib/layout/layout_test: StaticWarning -swarm/test/swarm_ui_lib/observable/observable_test: StaticWarning -swarm/test/swarm_ui_lib/touch/touch_test: StaticWarning -swarm/test/swarm_ui_lib/util/util_test: StaticWarning -swarm/test/swarm_ui_lib/view/view_test: StaticWarning - -[ $runtime == safari ] -swarm/test/swarm_test: Pass, Fail # Issue 14523 - -[ $runtime == vm ] -swarm: Skip - -[ $browser ] -swarm/test/swarm_ui_lib/touch/touch_test: Fail # This may be related to issue 157, Expectation: Solver. Expect.approxEquals(expected:9, actual:8.990625000000001, tolerance:0.0009) fails - -[ $compiler == dart2js && $runtime == chromeOnAndroid ] -swarm/test/swarm_test: Fail # TODO(kasperl): Please triage. -swarm/test/swarm_ui_lib/layout/layout_test: Fail # TODO(kasperl): Please triage. - -[ $compiler == dart2js && $runtime == ff ] -swarm/test/swarm_test: Fail # Issue 5633 diff --git a/samples-dev/swarm/test/swarm_test.dart b/samples-dev/swarm/test/swarm_test.dart deleted file mode 100644 index c7f39f9ef46..00000000000 --- a/samples-dev/swarm/test/swarm_test.dart +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library swarm_tests; - -import 'dart:html'; -import 'dart:async'; -import 'package:expect/expect.dart'; -import 'package:unittest/html_config.dart'; -import 'package:unittest/unittest.dart'; -import '../swarmlib.dart'; -import '../swarm_ui_lib/base/base.dart'; -import '../swarm_ui_lib/util/utilslib.dart'; - -// TODO(jmesserly): these would probably be easier to debug if they were written -// in the WebKit layout test style, so we could easy compare that the DOM is -// what we expect it to be after performing some simulated user actions. - -void main() { - useHtmlConfiguration(); - Swarm swarm = new Swarm(useCannedData: true); - UIStateProxy state = new UIStateProxy(swarm.sections); - swarm.state = state; - swarm.run(); - // TODO(jmesserly): should be adding the full stylesheet here - Dom.addStyle(''' - .story-content { - -webkit-column-width: 300px; - -webkit-column-gap: 26px; /* 2em */ - }'''); - - getStoryNode() => swarm.frontView.storyView.node; - - getView(Section section) { - return CollectionUtils.find( - swarm.frontView.sections.childViews, (view) => view.section == section); - } - - getHistory(Article article) { - final feed = article.dataSource; - return { - 'section': CollectionUtils - .find(swarm.sections, (s) => s.feeds.indexOf(feed, 0) >= 0) - .id, - 'feed': feed.id, - 'article': article.id - }; - } - - test('BackButton', () { - _serialInvokeAsync([ - () { - Expect.equals(null, swarm.frontView.storyView); // verify initial state - - // Make sure we've transitioned to the section - // In the real app, this isn't needed because ConveyorView fires the - // transition end event before we can click a story. - SectionView section = getView(swarm.sections[0]); - section.showSources(); - }, - () { - final item = swarm.sections[0].feeds[2].articles[1]; - state.loadFromHistory(getHistory(item)); - - Expect.equals(item, state.currentArticle.value); - - Expect.isFalse(getStoryNode().classes.contains(CSS.HIDDEN_STORY)); - - state.loadFromHistory({}); - - Expect.equals(null, state.currentArticle.value); - Expect.isTrue(getStoryNode().classes.contains(CSS.HIDDEN_STORY)); - } - ]); - }); - - test('StoryView', () { - state.clearHistory(); - - Expect.isTrue(getStoryNode().classes.contains(CSS.HIDDEN_STORY)); - - final dataSourceView = - swarm.frontView.currentSection.dataSourceView.getSubview(0); - final itemView = dataSourceView.itemsView.getSubview(0); - // TODO(jacobr): remove this null check. This is likely due to tests - // running without the correct CSS to size the window so that some items - // are visible. - if (itemView != null) { - click(itemView.node); - state.expectHistory([getHistory(itemView.item)]); - } - }); - - test('SliderMenu', () { - Expect.equals(getView(swarm.sections[0]), swarm.frontView.currentSection); - - // Find the first slider menu item, and click on the one next after it. - click(document.querySelectorAll('.${CSS.SM_ITEM}')[1]); - - Expect.equals(getView(swarm.sections[1]), swarm.frontView.currentSection); - - // Find the first menu item again and click on it. - click(document.querySelector('.${CSS.SM_ITEM}')); - - Expect.equals(getView(swarm.sections[0]), swarm.frontView.currentSection); - }); -} - -/** Triggers the click event, like [http://api.jquery.com/click/] */ -click(Element element) { - // TODO(rnystrom): This should be on the DOM API somewhere. - MouseEvent event = new MouseEvent('click'); - element.dispatchEvent(event); -} - -/** A proxy so we can intercept history calls */ -class UIStateProxy extends SwarmState { - List> history; - - UIStateProxy(Sections dataModel) : super(dataModel) { - clearHistory(); - } - - void pushToHistory() { - history.add(toHistory()); - super.pushToHistory(); - } - - void clearHistory() { - history = new List>(); - } - - void expectHistory(List> entries) { - Expect.equals(entries.length, history.length); - for (int i = 0; i < entries.length; i++) { - Map e = entries[i]; - Map h = history[i]; - Expect.equals(e['article'], h['article']); - } - clearHistory(); - } -} - -void _serialInvokeAsync(List closures) { - final length = closures.length; - if (length > 0) { - int i = 0; - void invokeNext() { - closures[i](); - i++; - if (i < length) { - Timer.run(expectAsync(invokeNext)); - } - } - - Timer.run(expectAsync(invokeNext)); - } -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/layout/css.dart b/samples-dev/swarm/test/swarm_ui_lib/layout/css.dart deleted file mode 100644 index e066463995f..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/layout/css.dart +++ /dev/null @@ -1,351 +0,0 @@ -// File generated by Dart CSS from source file layout.scss -// Do not edit. - -part of layout_tests; - -class AdaptiveLayout { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': 'auto minmax(min-content, 1fr)', - 'grid-rows': 'auto minmax(min-content, 1fr) auto', - }, - '#title': const { - 'grid-column': '1', - 'grid-row': '1', - }, - '#score': const { - 'grid-column': '1', - 'grid-row': '3', - }, - '#stats': const { - 'grid-column': '1', - 'grid-row': '2', - 'grid-row-align': 'start', - }, - '#board': const { - 'grid-column': '2', - 'grid-row': '1', - 'grid-row-span': '2', - }, - '#controls': const { - 'grid-column': '2', - 'grid-row': '3', - 'grid-column-align': 'center', - }, - }; -} - -class SourceIndependencePortrait { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-template': '"ta" "sa" "bb" "cc"', - 'grid-columns': 'auto minmax(min-content, 1fr)', - 'grid-rows': 'auto auto minmax(min-content, 1fr) auto', - }, - '#title': const { - 'grid-cell': '"t"', - }, - '#score': const { - 'grid-cell': '"s"', - }, - '#stats': const { - 'grid-cell': '"a"', - }, - '#board': const { - 'grid-cell': '"b"', - }, - '#controls': const { - 'grid-cell': '"c"', - }, - }; -} - -class SourceIndependenceLandscape { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-template': '"tb" "ab" "sc"', - 'grid-columns': 'auto minmax(min-content, 1fr)', - 'grid-rows': 'auto minmax(min-content, 1fr) auto', - }, - '#title': const { - 'grid-cell': '"t"', - }, - '#score': const { - 'grid-cell': '"s"', - }, - '#stats': const { - 'grid-cell': '"a"', - }, - '#board': const { - 'grid-cell': '"b"', - }, - '#controls': const { - 'grid-cell': '"c"', - }, - }; -} - -class GridLayering { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': - '"start" auto "track-start" 0.5fr "thumb-start" auto "fill-split" auto "thumb-end" 0.5fr "track-end" auto "end"', - }, - '#lower-label': const { - 'grid-column': '"start"', - }, - '#track': const { - 'grid-column': '"track-start" "track-end"', - 'grid-row-align': 'center', - }, - '#upper-label': const { - 'grid-column': '"track-end"', - }, - '#lower-fill': const { - 'grid-column': '"track-start" "fill-split"', - 'grid-row-align': 'center', - 'grid-layer': '5', - }, - '#upper-fill': const { - 'grid-column': '"fill-split" "track-end"', - 'grid-row-align': 'center', - 'grid-layer': '5', - }, - '#thumb': const { - 'grid-column': '"thumb-start" "thumb-end"', - 'grid-layer': '10', - }, - }; -} - -class GridLines_5 { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': '150px 1fr', - 'grid-rows': '50px 1fr 50px', - }, - '#item1': const { - 'grid-column': '2', - 'grid-row': '1 4', - }, - }; -} - -class GridLines_6 { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': '150px "item1-start" 1fr "item1-end"', - 'grid-rows': '"item1-start" 50px 1fr 50px "item1-end"', - }, - '#item1': const { - 'grid-column': '"item1-start" "item1-end"', - 'grid-row': '"item1-start" "item1-end"', - }, - }; -} - -class GridCells { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-template': '"ad" "bd" "cd"', - 'grid-columns': '150px 1fr', - 'grid-rows': '50px 1fr 50px', - }, - '#item2': const { - 'grid-cell': '"b"', - 'grid-row-align': 'start', - }, - '#item3': const { - 'grid-cell': '"b"', - 'grid-column-align': 'end', - 'grid-row-align': 'end', - }, - }; -} - -class StartEndingGridlines11a { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': '50px 1fr', - 'grid-rows': '"first" 250px 1fr 250px "last"', - }, - '#item': const { - 'grid-column': '1 3', - 'grid-row': '"first" "last"', - }, - }; -} - -class StartEndingGridlines11b { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': '50px 1fr', - 'grid-rows': '"first" 250px 1fr 250px "last"', - }, - '#item': const { - 'grid-column': 'start end', - 'grid-row': 'start end', - }, - }; -} - -class RepeatingColumnsRows { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': '10px ("content" 1fr 10px) [4]', - 'grid-rows': '1fr', - }, - '#col2': const { - 'grid-column': '2', - }, - '#col4': const { - 'grid-column': '4', - }, - '#col6': const { - 'grid-column': '6', - }, - '#col8': const { - 'grid-column': '8', - }, - }; -} - -class AnonymousGridCells { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-rows': '"header" auto "main" 1fr "footer" auto', - 'grid-columns': '1fr', - }, - '#header': const { - 'grid-row': '"header"', - 'grid-column': 'start', - }, - '#main': const { - 'grid-row': '"main"', - 'grid-column': 'start', - }, - '#footer': const { - 'grid-row': '"footer"', - 'grid-column': 'start', - }, - }; -} - -class ImplicitColumnsRows { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': '20px', - 'grid-rows': '20px', - }, - '#A': const { - 'grid-column': '1', - 'grid-row': '1', - 'grid-column-align': 'start', - 'grid-row-align': 'start', - }, - '#B': const { - 'grid-column': '5', - 'grid-row': '1', - 'grid-row-span': '2', - }, - '#C': const { - 'grid-column': '1', - 'grid-row': '2', - 'grid-column-span': '2', - }, - }; -} - -class AlignGridItems { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': '1fr 1fr', - 'grid-rows': '1fr 1fr', - }, - '#A': const { - 'grid-column': '1', - 'grid-row': '1', - 'grid-column-align': 'start', - 'grid-row-align': 'start', - }, - '#B': const { - 'grid-column': '2', - 'grid-row': '2', - 'grid-column-align': 'end', - 'grid-row-align': 'end', - }, - }; -} - -class DrawOrderGridItems { - // selector, properties - static const selectors = const { - '#grid': const { - 'display': '-dart-grid', - 'grid-columns': '1fr 1fr', - 'grid-rows': '1fr 1fr', - }, - '#A': const { - 'grid-column': '1', - 'grid-row': '2', - 'grid-column-span': '2', - 'grid-row-align': 'end', - }, - '#B': const { - 'grid-column': '1', - 'grid-row': '1', - 'grid-layer': '10', - }, - '#C': const { - 'grid-column': '2', - 'grid-row': '1', - 'grid-row-align': 'start', - 'margin-left': '-20px', - }, - '#D': const { - 'grid-column': '2', - 'grid-row': '2', - 'grid-column-align': 'end', - 'grid-row-align': 'start', - }, - '#E': const { - 'grid-column': '1', - 'grid-row': '1', - 'grid-column-span': '2', - 'grid-row-span': '2', - 'grid-layer': '5', - 'grid-column-align': 'center', - 'grid-row-align': 'center', - }, - }; -} - -class CSS { - // CSS class selectors: -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/layout/grid_examples.dart b/samples-dev/swarm/test/swarm_ui_lib/layout/grid_examples.dart deleted file mode 100644 index 3db78c79d39..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/layout/grid_examples.dart +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of layout_tests; - -/** - * The examples from the spec: [http://dev.w3.org/csswg/css3-grid-align/] - */ -// I've omitted examples that are subsumed by other examples, or examples -// that illustrate features (such as grid-flow) that are currently -// unsupported. -class GridExamples { - // Note: controls is positioned in row 3 in the example. Might be a bug in - // the example, or they're using flow. - // TODO(jmesserly): also needed to set "display: inline-block" to get - // horizontal content sizing to work. - static const styles = const { - '1 Adaptive Layouts': AdaptiveLayout.selectors, - '2a Source Independence: Portrait': SourceIndependencePortrait.selectors, - '2b Source Independence: Landscape': SourceIndependenceLandscape.selectors, - '3 Grid Layering of Elements': GridLayering.selectors, - '5 Grid Lines': GridLines_5.selectors, - '6 Grid Lines': GridLines_6.selectors, - '7 Grid Cells': GridCells.selectors, - '11a Starting and Ending Grid Lines': StartEndingGridlines11a.selectors, - '11b Starting and Ending Grid Lines': StartEndingGridlines11b.selectors, - '12 Repeating Columns and Rows': RepeatingColumnsRows.selectors, - '17 Anonymous Grid Cells': AnonymousGridCells.selectors, - '20 Implicit Columns and Rows': ImplicitColumnsRows.selectors, - '22 Grid Item Alignment': AlignGridItems.selectors, - '23 Drawing Order of Grid Items': DrawOrderGridItems.selectors - }; -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/layout/grid_layout_demo.dart b/samples-dev/swarm/test/swarm_ui_lib/layout/grid_layout_demo.dart deleted file mode 100644 index e12f2348f64..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/layout/grid_layout_demo.dart +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of layout_tests; - -/** - * An app for testing the grid layout system. - */ - -/** Creates a grid view structure given the CSS styles. */ -View createGrid(Map> styles) { - final gridStyle = styles['#grid']; - - final children = new List(); - for (final String id in styles.keys) { - // All selectors in this test are id selectors string the # prefix. - assert(id.startsWith('#')); - String elemId = id.substring(1); - if (elemId != 'grid') { - children.add(new MockView(elemId, styles[id])); - } - } - - return new MockCompositeView('grid', gridStyle, children); -} - -void _onLoad() { - var query = SwarmUri.parsequerySelector(window.location.search)['q']; - if (query != null && query.length == 1) { - query = SwarmUri.decodeComponent(query[0]); - addGridStyles('100%', '100%', 'margin:0px;'); - final view = createGrid(GridExamples.styles[query]); - view.addToDocument(document.body); - _addColorStyles(); - printMetrics(query); - } else { - final html = new StringBuffer(); - for (String ex in GridExamples.styles.keys) { - html.write(''); - } - document.body.innerHtml = html.toString(); - } -} - -void addGridStyles(String width, String height, [String margin = '']) { - // Use monospace font and fixed line-height so the text size is predictable. - // TODO(jmesserly): only tested on Chromium Mac/Linux - Dom.addStyle(''' - body { $margin } - #grid { - position: absolute; - width: $width; - height: $height; - border-color: black; - } - .grid-item { - border: solid 2px; - border-radius: 8px; - font-family:monospace; - font-size:16px; - line-height:20px; - } - '''); -} - -void _addColorStyles() { - final grid = document.body.querySelector('#grid'); - final colors = const [ - 'darkred', - 'darkorange', - 'darkgoldenrod', - 'darkgreen', - 'darkblue', - 'darkviolet' - ]; - int c = 0; - var node = grid.children[0]; - while (node != null) { - if (node.id != '') { - node.style.cssText += "color:" + colors[c++]; - } - node = node.nextElementSibling; - } -} - -class MockCompositeView extends CompositeView { - MockCompositeView(String id, Map styles, List childViews) : super('') { - node.id = id; - CollectionUtils.copyMap(customStyle, styles); - - for (final v in childViews) { - addChild(v); - } - } -} - -class MockView extends View { - MockView(String id, Map styles) - : super.fromNode( - new Element.html('
MockView-$id
')) { - node.id = id; - CollectionUtils.copyMap(customStyle, styles); - // TODO(jmesserly): this is needed to get horizontal content-sizing to work - node.style.display = 'inline-block'; - } -} - -void printMetrics(String example) { - final node = document.body.querySelector('#grid'); - String exampleId = example.split(' ')[0]; - final sb = new StringBuffer(); - sb.write("test('Spec Example $exampleId', () {\n"); - sb.write(" verifyExample('$example', {\n"); - final children = node.children; - - scheduleMicrotask(() { - for (int i = 0; i < children.length; i++) { - _appendMetrics(sb, children[i], ' '); - } - sb.write(' });\n'); - sb.write('});\n\n'); - window.console.log(sb.toString()); - }); -} - -void _appendMetrics(StringBuffer sb, Element node, [String indent = '']) { - String id = node.id; - num left = node.offsetLeft, top = node.offsetTop; - num width = node.offsetWidth, height = node.offsetHeight; - sb.write("${indent}'$id': [$left, $top, $width, $height],\n"); -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/layout/grid_layout_demo.html b/samples-dev/swarm/test/swarm_ui_lib/layout/grid_layout_demo.html deleted file mode 100644 index 6d199ec5249..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/layout/grid_layout_demo.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Grid Layout Demos - - - - - - - diff --git a/samples-dev/swarm/test/swarm_ui_lib/layout/layout.css b/samples-dev/swarm/test/swarm_ui_lib/layout/layout.css deleted file mode 100644 index cc4296e660d..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/layout/layout.css +++ /dev/null @@ -1,18 +0,0 @@ -/* File generated by SCSS from source layout.scss - * Do not edit. - */ - -/* @stylet export as AdaptiveLayout */ -/* @stylet export as SourceIndependencePortrait */ -/* @stylet export as SourceIndependenceLandscape */ -/* @stylet export as GridLayering */ -/* @stylet export as GridLines_5 */ -/* @stylet export as GridLines_6 */ -/* @stylet export as GridCells */ -/* @stylet export as StartEndingGridlines11a */ -/* @stylet export as StartEndingGridlines11b */ -/* @stylet export as RepeatingColumnsRows */ -/* @stylet export as AnonymousGridCells */ -/* @stylet export as ImplicitColumnsRows */ -/* @stylet export as AlignGridItems */ -/* @stylet export as DrawOrderGridItems */ diff --git a/samples-dev/swarm/test/swarm_ui_lib/layout/layout.scss b/samples-dev/swarm/test/swarm_ui_lib/layout/layout.scss deleted file mode 100644 index 2bff753c790..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/layout/layout.scss +++ /dev/null @@ -1,316 +0,0 @@ -/* Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file */ -/* for details. All rights reserved. Use of this source code is governed by a */ -/* BSD-style license that can be found in the LICENSE file. */ - -@stylet AdaptiveLayout { - #grid { - display: -dart-grid; - grid-columns: auto minmax(min-content, 1fr); - grid-rows: auto minmax(min-content, 1fr) auto; - } - #title { - grid-column: 1; - grid-row: 1; - } - #score { - grid-column: 1; - grid-row: 3; - } - #stats { - grid-column: 1; - grid-row: 2; - grid-row-align: start; - } - #board { - grid-column: 2; - grid-row: 1; - grid-row-span: 2; - } - #controls { - grid-column: 2; - grid-row: 3; - grid-column-align: center; - } -} - -@stylet SourceIndependencePortrait { - #grid { - display: -dart-grid; - grid-template: "ta" - "sa" - "bb" - "cc"; - grid-columns: auto minmax(min-content, 1fr); - grid-rows: auto auto minmax(min-content, 1fr) auto; - } - #title { - grid-cell: "t"; - } - #score { - grid-cell: "s"; - } - #stats { - grid-cell: "a"; - } - #board { - grid-cell: "b"; - } - #controls { - grid-cell: "c"; - } -} - -@stylet SourceIndependenceLandscape { - #grid { - display: -dart-grid; - grid-template: "tb" - "ab" - "sc"; - grid-columns: auto minmax(min-content, 1fr); - grid-rows: auto minmax(min-content, 1fr) auto; - } - #title { - grid-cell: "t"; - } - #score { - grid-cell: "s"; - } - #stats { - grid-cell: "a"; - } - #board { - grid-cell: "b"; - } - #controls { - grid-cell: "c"; - } -} - -@stylet GridLayering { - #grid { - display: -dart-grid; - grid-columns: "start" auto - "track-start" 0.5fr - "thumb-start" auto - "fill-split" auto - "thumb-end" 0.5fr - "track-end" auto - "end"; - } - #lower-label { - grid-column: "start"; - } - #track { - grid-column: "track-start" "track-end"; - grid-row-align: center; - } - #upper-label { - grid-column: "track-end"; - } - #lower-fill { - grid-column: "track-start" "fill-split"; - grid-row-align: center; grid-layer: 5; - } - #upper-fill { - grid-column: "fill-split" "track-end"; - grid-row-align: center; - grid-layer: 5; - } - #thumb { - grid-column: "thumb-start" "thumb-end"; - grid-layer: 10; - } -} - -@stylet GridLines_5 { - #grid { - display: -dart-grid; - grid-columns: 150px 1fr; - grid-rows: 50px 1fr 50px; - } - #item1 { - grid-column: 2; - grid-row: 1 4; - } -} - -@stylet GridLines_6 { - #grid { - display: -dart-grid; - grid-columns: 150px "item1-start" 1fr "item1-end"; - grid-rows: "item1-start" 50px 1fr 50px "item1-end"; - } - - #item1 { - grid-column: "item1-start" "item1-end"; - grid-row: "item1-start" "item1-end"; - } -} - -@stylet GridCells { - #grid { - display: -dart-grid; - grid-template: "ad" - "bd" - "cd"; - grid-columns: 150px 1fr; - grid-rows: 50px 1fr 50px; - } - #item2 { - grid-cell: "b"; - grid-row-align: start; - } - #item3 { - grid-cell: "b"; - grid-column-align: end; - grid-row-align: end; - } -} - -@stylet StartEndingGridlines11a { - #grid { - display: -dart-grid; - grid-columns: 50px 1fr; - grid-rows: "first" 250px 1fr 250px "last"; - } - #item { - grid-column:1 3; - grid-row: "first" "last"; - } -} - -@stylet StartEndingGridlines11b { - #grid { - display: -dart-grid; - grid-columns: 50px 1fr; - grid-rows: "first" 250px 1fr 250px "last"; - } - #item { - grid-column: start end; - grid-row: start end; - } -} - -@stylet RepeatingColumnsRows { - #grid { - display: -dart-grid; - grid-columns: 10px ("content" 1fr 10px)[4]; - grid-rows: 1fr; - } - #col2 { - grid-column: 2; - } - #col4 { - grid-column: 4; - } - #col6 { - grid-column: 6; - } - #col8 { - grid-column: 8; - } -} - -@stylet AnonymousGridCells { - #grid { - display: -dart-grid; - grid-rows: "header" auto "main" 1fr "footer" auto; - grid-columns: 1fr; - } - #header { - grid-row: "header"; - grid-column: start; - } - #main { - grid-row: "main"; - grid-column: start; - } - #footer { - grid-row: "footer"; - grid-column: start; - } -} - -@stylet ImplicitColumnsRows { - #grid { - display: -dart-grid; - grid-columns: 20px; - grid-rows: 20px; - } - #A { - grid-column: 1; - grid-row: 1; - grid-column-align: start; - grid-row-align: start; - } - #B { - grid-column: 5; - grid-row: 1; - grid-row-span: 2; - } - #C { - grid-column: 1; - grid-row: 2; - grid-column-span: 2; - } -} - -@stylet AlignGridItems { - #grid { - display: -dart-grid; - grid-columns: 1fr 1fr; - grid-rows: 1fr 1fr; - } - #A { - grid-column: 1; - grid-row: 1; - grid-column-align: start; - grid-row-align: start; - } - #B { - grid-column: 2; - grid-row: 2; - grid-column-align: end; - grid-row-align: end; - } -} - -@stylet DrawOrderGridItems { - #grid { - display: -dart-grid; - grid-columns: 1fr 1fr; - grid-rows: 1fr 1fr; - } - #A { - grid-column: 1; - grid-row: 2; - grid-column-span: 2; - grid-row-align: end; - } - #B { - grid-column: 1; - grid-row: 1; - grid-layer: 10; - } - #C { - grid-column: 2; - grid-row: 1; - grid-row-align: start; - margin-left: -20px; - } - #D { - grid-column: 2; - grid-row: 2; - grid-column-align: end; - grid-row-align: start; - } - #E { - grid-column: 1; grid-row: 1; - grid-column-span: 2; - grid-row-span: 2; - grid-layer: 5; - grid-column-align: center; - grid-row-align: center; - } - } - \ No newline at end of file diff --git a/samples-dev/swarm/test/swarm_ui_lib/layout/layout_test.dart b/samples-dev/swarm/test/swarm_ui_lib/layout/layout_test.dart deleted file mode 100644 index 4b1cf602684..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/layout/layout_test.dart +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library layout_tests; - -import 'package:expect/expect.dart'; -import 'dart:async'; -import 'dart:html'; -import '../../../swarm_ui_lib/base/base.dart'; -import '../../../swarm_ui_lib/layout/layout.dart'; -import '../../../swarm_ui_lib/view/view.dart'; -import '../../../swarm_ui_lib/util/utilslib.dart'; -import 'package:unittest/html_config.dart'; -import 'package:unittest/unittest.dart'; - -part 'grid_layout_demo.dart'; -part 'grid_examples.dart'; -part 'css.dart'; - -// TODO(jmesserly): these tests would be easier to work with if they were WebKit -// layout tests. The way content shell works is exactly what we want for -// testing layout: run the example and then print the element tree with metrics. -// The UnitTestSuite wrapper gets in our way here, because you can't "see" the -// test layout visually when you're debugging. -// See these links for more info: -// http://www.webkit.org/quality/testwriting.html -// http://www.w3.org/Style/CSS/Test/guidelines.html - -// TODO(jmesserly): need parser unit tests, especially error conditions - -/** - * Tests the grid layout. Currently based on examples from the spec at: - * [http://dev.w3.org/csswg/css3-grid-align/] - */ -main() { - useHtmlConfiguration(); - addGridStyles('400px', '400px'); - - test('Spec Example 1', () { - return verifyExample('1 Adaptive Layouts', { - 'title': [0, 0, 144, 24], - 'score': [0, 376, 144, 24], - 'stats': [0, 24, 144, 24], - 'board': [144, 0, 256, 376], - 'controls': [185, 376, 174, 24], - }); - }); - - test('Spec Example 2a', () { - return verifyExample('2a Source Independence: Portrait', { - 'title': [0, 0, 144, 24], - 'score': [0, 24, 144, 24], - 'stats': [144, 0, 256, 48], - 'board': [0, 48, 400, 328], - 'controls': [0, 376, 400, 24], - }); - }); - - test('Spec Example 2b', () { - return verifyExample('2b Source Independence: Landscape', { - 'title': [0, 0, 144, 24], - 'score': [0, 376, 144, 24], - 'stats': [0, 24, 144, 352], - 'board': [144, 0, 256, 376], - 'controls': [144, 376, 256, 24], - }); - }); - - // Not currently supported, issue with - // http://dev.w3.org/csswg/css3-grid-layout/#function-CalculateNormalizedFractionBreadth - //test('Spec Example 3', () { - // return verifyExample('3 Grid Layering of Elements', { - // 'lower-label': [0, 0, 204, 24], - // 'track': [204, 0, 144, 24], - // 'upper-label': [348, 0, 204, 24], - // 'lower-fill': [204, 0, 72, 24], - // 'upper-fill': [276, 0, 72, 24], - // 'thumb': [204, 0, 144, 24], - // }); - //}); - - test('Spec Example 5', () { - return verifyExample('5 Grid Lines', { - 'item1': [125, 0, 275, 400], - }); - }); - - test('Spec Example 6', () { - return verifyExample('6 Grid Lines', { - 'item1': [125, 0, 275, 400], - }); - }); - - test('Spec Example 7', () { - return verifyExample('7 Grid Cells', { - 'item2': [0, 50, 125, 24], - 'item3': [-19, 326, 144, 24], - }); - }); - - test('Spec Example 11a', () { - return verifyExample('11a Starting and Ending Grid Lines', { - 'item': [0, 0, 400, 400], - }); - }); - - test('Spec Example 11b', () { - return verifyExample('11b Starting and Ending Grid Lines', { - 'item': [0, 0, 400, 400], - }); - }); - - test('Spec Example 12', () { - return verifyExample('12 Repeating Columns and Rows', { - 'col2': [10, 0, 88, 400], - 'col4': [108, 0, 87, 400], - 'col6': [205, 0, 88, 400], - 'col8': [303, 0, 87, 400], - }); - }); - - test('Spec Example 17', () { - return verifyExample('17 Anonymous Grid Cells', { - 'header': [0, 0, 400, 24], - 'main': [0, 24, 400, 352], - 'footer': [0, 376, 400, 24], - }); - }); - - // Not currently supported, issue with - // http://dev.w3.org/csswg/css3-grid-layout/#function-CalculateNormalizedFractionBreadth - //test('Spec Example 20', () { - // return verifyExample('20 Implicit Columns and Rows', { - // 'A': [0, 0, 104, 24], - // 'B': [104, 0, 104, 44], - // 'C': [0, 20, 104, 24], - // }); - //}); - - test('Spec Example 22', () { - return verifyExample('22 Grid Item Alignment', { - 'A': [0, 0, 104, 24], - 'B': [296, 376, 104, 24], - }); - }); - - test('Spec Example 23', () { - return verifyExample('23 Drawing Order of Grid Items', { - 'A': [0, 376, 400, 24], - 'B': [0, 0, 200, 200], - 'C': [200, 0, 200, 24], - 'D': [296, 200, 104, 24], - 'E': [148, 188, 104, 24], - }); - }); -} - -// Note: to debug failures, best bet is to use GridLayoutDemo to run an -// individual asyncTest and see the resulting layout. - -Future usingGrid(String example, Future test_(View grid)) { - final grid = createGrid(GridExamples.styles[example]); - grid.addToDocument(document.body); - return new Future.delayed(new Duration()).then((_) { - return test_(grid); - }).then((_) { - grid.removeFromDocument(); - }); -} - -Future verifyGrid(String example, [Map expected = null]) { - printMetrics(example); - if (expected == null) { - return new Future.value(); - } - - for (String name in expected.keys) { - final values = expected[name]; - final node = document.body.querySelector('#$name'); - Expect.isNotNull(node); - return new Future.value().then((_) { - Expect.equals(values[0], node.offsetLeft); - Expect.equals(values[1], node.offsetTop); - Expect.equals(values[2], node.offsetWidth); - Expect.equals(values[3], node.offsetHeight); - }); - } -} - -Future verifyExample(String example, [Map expected = null]) { - return usingGrid(example, (grid) => verifyGrid(example, expected)); -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/observable/abstract_observable_tests.dart b/samples-dev/swarm/test/swarm_ui_lib/observable/abstract_observable_tests.dart deleted file mode 100644 index 49c8e85fed3..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/observable/abstract_observable_tests.dart +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of observable_tests; - -testAbstractObservable() { - group('addChangeListener()', () { - test('adding the same listener twice returns false the second time', () { - final target = new AbstractObservable(); - final listener = (e) {}; - - expect(target.addChangeListener(listener), isTrue); - expect(target.addChangeListener(listener), isFalse); - }); - - test('modifies listeners list', () { - // check that add/remove works, see contents of listeners too - final target = new AbstractObservable(); - final l1 = (e) {}; - final l2 = (e) {}; - final l3 = (e) {}; - final l4 = (e) {}; - - expect(target.listeners, orderedEquals([])); - - target.addChangeListener(l1); - expect(target.listeners, orderedEquals([l1])); - - target.addChangeListener(l2); - expect(target.listeners, orderedEquals([l1, l2])); - - target.addChangeListener(l3); - target.addChangeListener(l4); - expect(target.listeners, orderedEquals([l1, l2, l3, l4])); - - target.removeChangeListener(l4); - expect(target.listeners, orderedEquals([l1, l2, l3])); - - target.removeChangeListener(l2); - expect(target.listeners, orderedEquals([l1, l3])); - - target.removeChangeListener(l1); - expect(target.listeners, orderedEquals([l3])); - - target.removeChangeListener(l3); - expect(target.listeners, orderedEquals([])); - }); - }); - - test('fires immediately if no batch', () { - // If no batch is created, a summary should be automatically created and - // fired on each property change. - final target = new AbstractObservable(); - EventSummary res = null; - target.addChangeListener((summary) { - expect(res, isNull); - res = summary; - expect(res, isNotNull); - }); - - target.recordPropertyUpdate('pM', 10, 11); - - expect(res, isNotNull); - expect(res.events, hasLength(1)); - validateUpdate(res.events[0], target, 'pM', null, 10, 11); - res = null; - - target.recordPropertyUpdate('pL', '11', '13'); - - expect(res, isNotNull); - expect(res.events, hasLength(1)); - validateUpdate(res.events[0], target, 'pL', null, '11', '13'); - }); -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/observable/change_event_tests.dart b/samples-dev/swarm/test/swarm_ui_lib/observable/change_event_tests.dart deleted file mode 100644 index 1819fb6a05d..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/observable/change_event_tests.dart +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of observable_tests; - -testChangeEvent() { - test('constructor', () { - // create property, list, global and check the proper initialization. - final target = new AbstractObservable(); - - validateUpdate(new ChangeEvent.property(target, 'pK', 33, '12'), target, - 'pK', null, 33, '12'); - - validateUpdate( - new ChangeEvent.list(target, ChangeEvent.UPDATE, 3, 33, '12'), - target, - null, - 3, - 33, - '12'); - - validateInsert( - new ChangeEvent.list(target, ChangeEvent.INSERT, 3, 33, null), - target, - null, - 3, - 33); - - validateRemove( - new ChangeEvent.list(target, ChangeEvent.REMOVE, 3, null, '12'), - target, - null, - 3, - '12'); - - validateGlobal( - new ChangeEvent.list(target, ChangeEvent.GLOBAL, null, null, null), - target); - }); -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/observable/event_batch_tests.dart b/samples-dev/swarm/test/swarm_ui_lib/observable/event_batch_tests.dart deleted file mode 100644 index 0e7a7cc2722..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/observable/event_batch_tests.dart +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of observable_tests; - -testEventBatch() { - test('EventBatch', () { - // check that all events are fired at the end. Use all record methods - // in abstract observable - final target = new AbstractObservable(); - EventSummary res = null; - target.addChangeListener((summary) { - expect(res, isNull); - res = summary; - expect(res, isNotNull); - }); - - final f = EventBatch.wrap((e) { - target.recordPropertyUpdate('pM', 10, 11); - target.recordPropertyUpdate('pL', '11', '13'); - target.recordListUpdate(2, 'a', 'b'); - target.recordListInsert(5, 'a'); - target.recordListRemove(4, 'c'); - target.recordGlobalChange(); - }); - - expect(res, isNull); - f(null); - expect(res, isNotNull); - - expect(res.events, hasLength(6)); - validateUpdate(res.events[0], target, 'pM', null, 10, 11); - validateUpdate(res.events[1], target, 'pL', null, '11', '13'); - validateUpdate(res.events[2], target, null, 2, 'a', 'b'); - validateInsert(res.events[3], target, null, 5, 'a'); - validateRemove(res.events[4], target, null, 4, 'c'); - validateGlobal(res.events[5], target); - }); -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/observable/observable_list_tests.dart b/samples-dev/swarm/test/swarm_ui_lib/observable/observable_list_tests.dart deleted file mode 100644 index aaffb92a95e..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/observable/observable_list_tests.dart +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of observable_tests; - -testObservableList() { - test('ObservableList', () { - final arr = new ObservableList(); - - // Add some initial data before listening - arr.add(1); - arr.add(2); - arr.add(3); - arr.add(1); - arr.add(3); - arr.add(4); - - expect(arr, orderedEquals([1, 2, 3, 1, 3, 4])); - - // Add a listener that saves the events - EventSummary res = null; - arr.addChangeListener((summary) { - expect(res, isNull); - res = summary; - expect(res, isNotNull); - }); - - // execute some code with readonly operations only - expect(res, isNull); - bool called = false; - EventBatch.wrap((e) { - expect(arr, hasLength(6)); - expect(arr[0], equals(1)); - // TODO(sigmund): why we need write startIndex? it should be optional. - expect(arr.indexOf(4, 0), equals(5)); - expect(arr.indexOf(1, 0), equals(0)); - expect(arr.indexOf(1, 1), equals(3)); - // TODO(rnystrom): Get rid of second arg when lastIndexOf has default. - expect(arr.lastIndexOf(1, arr.length - 1), equals(3)); - expect(arr.last, equals(4)); - final copy = new List(); - arr.forEach((i) { - copy.add(i); - }); - expect(copy, orderedEquals([1, 2, 3, 1, 3, 4])); - called = true; - })(null); - expect(called, isTrue); - expect(res, isNull); // no change from read-only operators - - // execute some code with mutations - expect(res, isNull); - called = false; - expect(arr, orderedEquals([1, 2, 3, 1, 3, 4])); - EventBatch.wrap((e) { - arr.add(5); // 1 2 3 1 3 4(5) - arr.add(6); // 1 2 3 1 3 4 5(6) - arr[1] = arr[arr.length - 1]; // 1(6)3 1 3 4 5 6 - arr.add(7); // 1 6 3 1 3 4 5 6(7) - arr[5] = arr[8]; // 1 6 3 1 3(7)5 6 7 - arr.add(42); // 1 6 3 1 3 7 5 6 7(42) - expect(arr.removeAt(3), equals(1)); // 1 6 3( )3 7 5 6 7 42 - expect(arr.removeFirstElement(3), isTrue); // 1 6( ) 3 7 5 6 7 42 - expect(arr.removeLast(), equals(42)); // 1 6 3 7 5 6 7( ) - expect(arr.removeAllElements(6), equals(2)); // 1( ) 3 7 5( )7 - called = true; - })(null); - expect(called, isTrue); - expect(res, isNotNull); - expect(res.events, hasLength(11)); - validateInsert(res.events[0], arr, null, 6, 5); - validateInsert(res.events[1], arr, null, 7, 6); - validateUpdate(res.events[2], arr, null, 1, 6, 2); - validateInsert(res.events[3], arr, null, 8, 7); - validateUpdate(res.events[4], arr, null, 5, 7, 4); - validateInsert(res.events[5], arr, null, 9, 42); - validateRemove(res.events[6], arr, null, 3, 1); - validateRemove(res.events[7], arr, null, 2, 3); - validateRemove(res.events[8], arr, null, 7, 42); - validateRemove(res.events[9], arr, null, 1, 6); - validateRemove(res.events[10], arr, null, 4, 6); - expect(arr, orderedEquals([1, 3, 7, 5, 7])); - - res = null; - expect(res, isNull); - called = false; - // execute global mutations like sort and clear - EventBatch.wrap((e) { - arr.add(1); - arr.add(4); - arr.add(10); - arr.add(9); - arr.sort((int a, int b) { - return a - b; - }); - called = true; - })(null); - expect(called, isTrue); - expect(res, isNotNull); - expect(res.events.length, equals(5)); - validateInsert(res.events[0], arr, null, 5, 1); - validateInsert(res.events[1], arr, null, 6, 4); - validateInsert(res.events[2], arr, null, 7, 10); - validateInsert(res.events[3], arr, null, 8, 9); - validateGlobal(res.events[4], arr); - expect(arr, orderedEquals([1, 1, 3, 4, 5, 7, 7, 9, 10])); - - res = null; - expect(res, isNull); - called = false; - EventBatch.wrap((e) { - arr.clear(); - called = true; - })(null); - expect(called, isTrue); - expect(res, isNotNull); - expect(res.events, hasLength(1)); - validateGlobal(res.events[0], arr); - expect(arr, orderedEquals([])); - }); -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/observable/observable_test.dart b/samples-dev/swarm/test/swarm_ui_lib/observable/observable_test.dart deleted file mode 100644 index 296ecbe1f37..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/observable/observable_test.dart +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library observable_tests; - -import '../../../swarm_ui_lib/observable/observable.dart'; -import 'package:unittest/html_config.dart'; -import 'package:unittest/unittest.dart'; - -part 'abstract_observable_tests.dart'; -part 'change_event_tests.dart'; -part 'event_batch_tests.dart'; -part 'observable_list_tests.dart'; -part 'observable_value_tests.dart'; - -void main() { - useHtmlConfiguration(); - group('AbstractObservable', testAbstractObservable); - group('ChangeEvent', testChangeEvent); - group('EventBatch', testEventBatch); - group('ObservableList', testObservableList); - group('ObservableValue', testObservableValue); -} - -void validateEvent(ChangeEvent e, target, pName, index, type, newVal, oldVal) { - expect(e.target, equals(target)); - expect(e.propertyName, equals(pName)); - expect(e.index, equals(index)); - expect(e.type, equals(type)); - expect(e.newValue, equals(newVal)); - expect(e.oldValue, equals(oldVal)); -} - -void validateGlobal(ChangeEvent e, target) { - validateEvent(e, target, null, null, ChangeEvent.GLOBAL, null, null); -} - -void validateInsert(ChangeEvent e, target, pName, index, newVal) { - validateEvent(e, target, pName, index, ChangeEvent.INSERT, newVal, null); -} - -void validateRemove(ChangeEvent e, target, pName, index, oldVal) { - validateEvent(e, target, pName, index, ChangeEvent.REMOVE, null, oldVal); -} - -void validateUpdate(ChangeEvent e, target, pName, index, newVal, oldVal) { - validateEvent(e, target, pName, index, ChangeEvent.UPDATE, newVal, oldVal); -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/observable/observable_value_tests.dart b/samples-dev/swarm/test/swarm_ui_lib/observable/observable_value_tests.dart deleted file mode 100644 index 2ee55c11678..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/observable/observable_value_tests.dart +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of observable_tests; - -testObservableValue() { - test('ObservableValue', () { - final value = new ObservableValue('initial'); - expect(value.value, equals('initial')); - - // Set value. - value.value = 'new'; - expect(value.value, equals('new')); - - // Change event is sent when value is changed. - EventSummary result = null; - value.addChangeListener((summary) { - expect(result, isNull); - result = summary; - expect(result, isNotNull); - }); - - value.value = 'newer'; - - expect(result, isNotNull); - expect(result.events.length, equals(1)); - validateUpdate(result.events[0], value, 'value', null, 'newer', 'new'); - }); - - test('does not raise event if unchanged', () { - final value = new ObservableValue('foo'); - expect(value.value, equals('foo')); - - bool called = false; - value.addChangeListener((summary) { - called = true; - }); - - // Set it to the same value. - value.value = 'foo'; - - // Should not have gotten an event. - expect(called, isFalse); - }); -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/touch/touch_test.dart b/samples-dev/swarm/test/swarm_ui_lib/touch/touch_test.dart deleted file mode 100644 index 1bd34369bfb..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/touch/touch_test.dart +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library touchTests; - -import 'dart:html'; // TODO(rnystrom): Only needed to tell architecture.py -// that this is a web test. Come up with cleaner solution. -import 'package:unittest/html_config.dart'; -import 'package:unittest/unittest.dart'; -import '../../../swarm_ui_lib/touch/touch.dart'; - -main() { - useHtmlConfiguration(); - test('Solver', () { - expect(Solver.solve((x) => x * x, 81, 10), closeTo(9, 0.1)); - expect(Solver.solve((x) => x * x, 0, 10), closeTo(0, 0.1)); - expect(Solver.solve((x) => x * x, 1.5625, 10), closeTo(1.25, 0.1)); - expect(Solver.solve((x) => 1 / x, 10, 1), closeTo(0.1, 0.1)); - }); - - group('Momentum', () { - test('SingleDimensionPhysics', () { - expect(new SingleDimensionPhysics().solve(0, 0, 1), equals(0)); - expect(new SingleDimensionPhysics().solve(0, 5, 1), equals(0)); - expect(new SingleDimensionPhysics().solve(0, 100, 1), equals(0)); - expect(new SingleDimensionPhysics().solve(0, 100, 0.5), equals(0)); - }); - - test('TimeoutMomentum()', () { - final delegate = new TestMomentumDelegate(); - final momentum = new TimeoutMomentum(null); - }); - }); -} - -class TestMomentumDelegate { - Function onDecelerateCallback; - Function onDecelerationEndCallback; - - void onDecelerate(num x, num y, - [num duration = 0, String timingFunction = null]) { - onDecelerateCallback(x, y, duration, timingFunction); - } - - /** - * Callback for end of deceleration. - */ - void onDecelerationEnd() { - onDecelerationEndCallback(); - } -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/util/util_test.dart b/samples-dev/swarm/test/swarm_ui_lib/util/util_test.dart deleted file mode 100644 index 97b589075a2..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/util/util_test.dart +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library util_tests; - -import 'dart:html'; -import 'package:unittest/html_config.dart'; -import 'package:unittest/unittest.dart'; -import '../../../swarm_ui_lib/util/utilslib.dart'; - -main() { - useHtmlConfiguration(); - test('insertAt', () { - var a = []; - CollectionUtils.insertAt(a, 0, 1); - expect(a, orderedEquals([1])); - - CollectionUtils.insertAt(a, 0, 2); - expect(a, orderedEquals([2, 1])); - - CollectionUtils.insertAt(a, 0, 5); - CollectionUtils.insertAt(a, 0, 4); - CollectionUtils.insertAt(a, 0, 3); - expect(a, orderedEquals([3, 4, 5, 2, 1])); - - a = []; - CollectionUtils.insertAt(a, 0, 1); - expect(a, orderedEquals([1])); - - CollectionUtils.insertAt(a, 1, 2); - expect(a, orderedEquals([1, 2])); - - CollectionUtils.insertAt(a, 1, 3); - CollectionUtils.insertAt(a, 3, 4); - CollectionUtils.insertAt(a, 3, 5); - expect(a, orderedEquals([1, 3, 2, 5, 4])); - }); - - test('defaultString', () { - expect(StringUtils.defaultString(null), isEmpty); - expect(StringUtils.defaultString(''), isEmpty); - expect(StringUtils.defaultString('test'), equals('test')); - }); -} diff --git a/samples-dev/swarm/test/swarm_ui_lib/view/view_test.dart b/samples-dev/swarm/test/swarm_ui_lib/view/view_test.dart deleted file mode 100644 index 663b45b3a88..00000000000 --- a/samples-dev/swarm/test/swarm_ui_lib/view/view_test.dart +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library view_tests; - -import 'dart:html'; -import '../../../swarm_ui_lib/view/view.dart'; -import 'package:unittest/html_config.dart'; -import 'package:unittest/unittest.dart'; - -void main() { - useHtmlConfiguration(); - test('does not render immediately', () { - final view = new TestView(); - expect(view.isRendered, isFalse); - - view.addToDocument(document.body); - expect(view.isRendered, isTrue); - }); - - group('addToDocument()', () { - test('causes view to render', () { - final view = new TestView(); - view.addToDocument(document.body); - expect(view.isRendered, isTrue); - }); - - test('calls afterRender()', () { - var result = ''; - final view = new TestView(); - view.renderFn = () { - result = '${result}render'; - return new Element.html('
'); - }; - - view.afterRenderFn = (node) { - result = '${result}after'; - }; - - view.addToDocument(document.body); - expect(result, equals('renderafter')); - }); - - test('calls enterDocument()', () { - final view = new TestView(); - bool entered = false; - view.enterDocumentFn = () { - entered = true; - }; - - view.addToDocument(document.body); - expect(entered, isTrue); - }); - }); - - group('afterRender()', () { - test('passes rendered node', () { - final rendered = new Element.html('
'); - final view = new TestView(); - view.renderFn = () => rendered; - view.afterRenderFn = (node) { - expect(node, equals(rendered)); - }; - - view.addToDocument(document.body); - }); - }); - - group('childViewAdded()', () { - test('calls enterDocument() if parent is in document', () { - final parent = new TestView(); - parent.addToDocument(document.body); - - bool entered = false; - final child = new TestView(); - child.enterDocumentFn = () { - entered = true; - }; - - // Add the child. - parent.childViews = [child]; - parent.childViewAdded(child); - - expect(entered, isTrue); - }); - - test('does not call enterDocument() if parent is not in document', () { - final parent = new TestView(); - - bool entered = false; - final child = new TestView(); - child.enterDocumentFn = () { - entered = true; - }; - - // Add the child. - parent.childViews = [child]; - parent.childViewAdded(child); - - expect(entered, isFalse); - }); - - test('calls enterDocument() each time added', () { - final parent = new TestView(); - parent.addToDocument(document.body); - - var entered = 0; - final child = new TestView(); - child.enterDocumentFn = () { - entered++; - }; - - // Add the child. - parent.childViews = [child]; - parent.childViewAdded(child); - parent.childViewRemoved(child); - parent.childViewAdded(child); - parent.childViewRemoved(child); - parent.childViewAdded(child); - parent.childViewRemoved(child); - - expect(entered, equals(3)); - }); - }); - - group('childViewRemoved()', () { - test('calls exitDocument() if parent is in document', () { - final parent = new TestView(); - parent.addToDocument(document.body); - - bool exited = false; - final child = new TestView(); - child.exitDocumentFn = () { - exited = true; - }; - - // Remove the child. - parent.childViews = []; - parent.childViewRemoved(child); - - expect(exited, isTrue); - }); - - test('does not call exitDocument() if parent is not in document', () { - final parent = new TestView(); - - bool exited = false; - final child = new TestView(); - child.exitDocumentFn = () { - exited = true; - }; - - // Remove the child. - parent.childViews = []; - parent.childViewRemoved(child); - - expect(exited, isFalse); - }); - - test('calls exitDocument() each time removed', () { - final parent = new TestView(); - parent.addToDocument(document.body); - - var exited = 0; - final child = new TestView(); - child.exitDocumentFn = () { - exited++; - }; - - // Add the child. - parent.childViews = [child]; - parent.childViewAdded(child); - parent.childViewRemoved(child); - parent.childViewAdded(child); - parent.childViewRemoved(child); - parent.childViewAdded(child); - parent.childViewRemoved(child); - - expect(exited, equals(3)); - }); - }); - - group('enterDocument()', () { - test('children are called before parents', () { - var result = ''; - - final parent = new TestView(); - parent.enterDocumentFn = () { - result = '${result}parent'; - }; - - final child = new TestView(); - child.enterDocumentFn = () { - result = '${result}child'; - }; - - parent.childViews = [child]; - - parent.addToDocument(document.body); - expect(result, equals('childparent')); - }); - }); -} - -class TestView extends View { - Function renderFn; - Function afterRenderFn; - Function enterDocumentFn; - Function exitDocumentFn; - List childViews; - - TestView() : childViews = [] { - // Default behavior. - renderFn = () => new Element.html('
'); - afterRenderFn = (node) {}; - enterDocumentFn = () {}; - exitDocumentFn = () {}; - } - - Element render() => renderFn(); - void afterRender(Element node) { - afterRenderFn(node); - } - - void enterDocument() { - enterDocumentFn(); - } - - void exitDocument() { - exitDocumentFn(); - } -}