From ab9f1d71da0e97d23d2e33bcbde1de214f5e734b Mon Sep 17 00:00:00 2001 From: Marc Fisher II Date: Mon, 12 Jan 2015 10:08:17 -0800 Subject: [PATCH 1/2] Format dart file with dartformat. --- dart/lib/html.dart | 109 ++++++++++++++++----------------- dart/lib/src/annotations.dart | 8 +-- dart/lib/src/core.dart | 48 ++++++--------- dart/lib/webdriver.dart | 60 ++++++++---------- dart/test/html_test.dart | 12 ++-- dart/test/page_objects.dart | 83 ++++++++++++++----------- dart/test/pageloader_test.dart | 40 ++++-------- 7 files changed, 165 insertions(+), 195 deletions(-) diff --git a/dart/lib/html.dart b/dart/lib/html.dart index d566b689..7ffd9eff 100644 --- a/dart/lib/html.dart +++ b/dart/lib/html.dart @@ -58,8 +58,7 @@ class HtmlPageLoader extends BasePageLoader { return new HtmlPageLoader._(globalContext, clock); } - HtmlPageLoader._(Node globalContext, Clock clock) - : super(clock) { + HtmlPageLoader._(Node globalContext, Clock clock) : super(clock) { this._globalContext = new HtmlPageLoaderElement(globalContext, this); this._mouse = new _HtmlMouse(this); } @@ -80,7 +79,6 @@ class HtmlPageLoader extends BasePageLoader { } class _HtmlMouse implements PageLoaderMouse { - final HtmlPageLoader loader; int clientX = 0; @@ -114,12 +112,13 @@ class _HtmlMouse implements PageLoaderMouse { int get _borderWidth => (window.outerWidth - window.innerWidth) ~/ 2; int get screenX => window.screenLeft + _borderWidth + clientX; int get screenY => window.screenTop + window.outerHeight - - window.innerHeight - _borderWidth + clientY; + window.innerHeight - + _borderWidth + + clientY; void dispatchEvent(String type, _ElementPageLoaderElement eventTarget, [int button = 0]) { - var event = new MouseEvent( - type, + var event = new MouseEvent(type, button: button, clientX: clientX, clientY: clientY, @@ -179,11 +178,10 @@ abstract class HtmlPageLoaderElement implements PageLoaderElement { int get hashCode => node.hashCode; @override - bool operator ==(other) => - other != null && - other.runtimeType == runtimeType && - other.node == node && - other.loader == loader; + bool operator ==(other) => other != null && + other.runtimeType == runtimeType && + other.node == node && + other.loader == loader; @override String toString() => '$runtimeType<${node.toString()}>'; @@ -197,8 +195,8 @@ abstract class HtmlPageLoaderElement implements PageLoaderElement { // https://code.google.com/p/dart/issues/detail?id=13902 void _fireKeyPressEvents(Element element, String keys) { for (int charCode in keys.codeUnits) { - element.dispatchEvent( - new KeyEvent('keypress', charCode: charCode).wrapped); + element + .dispatchEvent(new KeyEvent('keypress', charCode: charCode).wrapped); } } } @@ -333,47 +331,48 @@ class _DocumentPageLoaderElement extends HtmlPageLoaderElement { class _ElementAttributes extends PageLoaderAttributes { static const _BOOLEAN_ATTRIBUTES = const [ - 'async', - 'autofocus', - 'autoplay', - 'checked', - 'compact', - 'complete', - 'controls', - 'declare', - 'defaultchecked', - 'defaultselected', - 'defer', - 'disabled', - 'draggable', - 'ended', - 'formnovalidate', - 'hidden', - 'indeterminate', - 'iscontenteditable', - 'ismap', - 'itemscope', - 'loop', - 'multiple', - 'muted', - 'nohref', - 'noresize', - 'noshade', - 'novalidate', - 'nowrap', - 'open', - 'paused', - 'pubdate', - 'readonly', - 'required', - 'reversed', - 'scoped', - 'seamless', - 'seeking', - 'selected', - 'spellcheck', - 'truespeed', - 'willvalidate']; + 'async', + 'autofocus', + 'autoplay', + 'checked', + 'compact', + 'complete', + 'controls', + 'declare', + 'defaultchecked', + 'defaultselected', + 'defer', + 'disabled', + 'draggable', + 'ended', + 'formnovalidate', + 'hidden', + 'indeterminate', + 'iscontenteditable', + 'ismap', + 'itemscope', + 'loop', + 'multiple', + 'muted', + 'nohref', + 'noresize', + 'noshade', + 'novalidate', + 'nowrap', + 'open', + 'paused', + 'pubdate', + 'readonly', + 'required', + 'reversed', + 'scoped', + 'seamless', + 'seeking', + 'selected', + 'spellcheck', + 'truespeed', + 'willvalidate' + ]; final Element _node; @@ -434,7 +433,7 @@ class _ElementAttributes extends PageLoaderAttributes { try { // 7.1 result = reflect(_node).getField(new Symbol(name)).reflectee; - } catch (e) { /* 7.2 - 7.3 ignore and default to attribute value or null*/ } + } catch (e) {/* 7.2 - 7.3 ignore and default to attribute value or null*/} if (result is bool) { return result ? 'true' : null; diff --git a/dart/lib/src/annotations.dart b/dart/lib/src/annotations.dart index cdc719fa..484f0fab 100644 --- a/dart/lib/src/annotations.dart +++ b/dart/lib/src/annotations.dart @@ -96,13 +96,11 @@ class Returns { } class ReturnsList extends Returns { - const ReturnsList(Type type) : super(type); } /// Filters element based on visibility. class WithState extends ElementFilter implements HasFilterFinderOptions { - final bool _displayed; const WithState._(this._displayed); @@ -180,7 +178,6 @@ class _Root implements Finder, HasFilterFinderOptions { /// Keeps only [PageLoaderElement]s that have the given attribute with the /// given value. class WithAttribute extends ElementFilter { - final String name; final String value; @@ -194,7 +191,6 @@ class WithAttribute extends ElementFilter { /// Keeps only [PageLoaderElement]s that correspond to the given tag. class IsTag extends ElementFilter { - final String tagName; const IsTag(this.tagName); @@ -316,8 +312,8 @@ class Global implements Finder { @override List findElements(PageLoaderElement context) => - annotation.findElements(context.loader.globalContext); + annotation.findElements(context.loader.globalContext); @override String toString() => '@Global($annotation)'; -} \ No newline at end of file +} diff --git a/dart/lib/src/core.dart b/dart/lib/src/core.dart index 982573c8..5668e355 100644 --- a/dart/lib/src/core.dart +++ b/dart/lib/src/core.dart @@ -53,13 +53,13 @@ abstract class BasePageLoader implements PageLoader { new _ClassInfo(type).getInstance(context, this); @override - waitForValue(condition(), {Duration timeout: _DEFAULT_WAIT, Duration interval: - _DEFAULT_INTERVAL}) => + waitForValue(condition(), {Duration timeout: _DEFAULT_WAIT, + Duration interval: _DEFAULT_INTERVAL}) => waitFor(condition, isNotNull, timeout: timeout, interval: interval); @override - waitFor(condition(), Matcher matcher, {Duration timeout: _DEFAULT_WAIT, - Duration interval: _DEFAULT_INTERVAL}) { + waitFor(condition(), Matcher matcher, + {Duration timeout: _DEFAULT_WAIT, Duration interval: _DEFAULT_INTERVAL}) { var endTime = clock.now.add(timeout); while (true) { try { @@ -87,9 +87,8 @@ class _Lazy implements Lazy { } class _ClassInfo { - - static final Map _classInfoCache = {}; + static final Map _classInfoCache = + {}; final ClassMirror _class; final List<_FieldInfo> _fields; @@ -119,11 +118,7 @@ class _ClassInfo { } return new _ClassInfo._( - type, - _fieldInfos(type), - finder, - filters, - finderIsOptional); + type, _fieldInfos(type), finder, filters, finderIsOptional); }); _ClassInfo._(this._class, this._fields, this._finder, this._filters, @@ -213,7 +208,6 @@ class _ClassInfo { } abstract class _FieldInfo { - factory _FieldInfo(DeclarationMirror field) { var finder; var filters = new List(); @@ -336,7 +330,6 @@ abstract class _FieldInfo { } abstract class _FinderFieldInfo implements _FieldInfo { - final Symbol _fieldName; _FinderFieldInfo(this._fieldName); @@ -356,21 +349,18 @@ abstract class _FinderFieldInfo implements _FieldInfo { } class _FinderSingleFieldInfo extends _FinderFieldInfo { - final Finder _finder; final List _filters; final ClassMirror _instanceType; final bool _isOptional; _FinderSingleFieldInfo(Symbol fieldName, this._finder, this._filters, - this._instanceType, this._isOptional) - : super(fieldName); + this._instanceType, this._isOptional) : super(fieldName); @override calculateFieldValue(PageLoaderElement context, BasePageLoader loader) { var element = _getElement(context, _finder, _filters, _isOptional); - if (_instanceType.simpleName != #PageLoaderElement && - element != null) { + if (_instanceType.simpleName != #PageLoaderElement && element != null) { element = loader._getInstance(_instanceType, element); } return element; @@ -378,28 +368,27 @@ class _FinderSingleFieldInfo extends _FinderFieldInfo { } class _FinderListFieldInfo extends _FinderFieldInfo { - final Finder _finder; final List _filters; final ClassMirror _instanceType; - _FinderListFieldInfo(Symbol fieldName, this._finder, this._filters, - this._instanceType) + _FinderListFieldInfo( + Symbol fieldName, this._finder, this._filters, this._instanceType) : super(fieldName); @override calculateFieldValue(PageLoaderElement context, BasePageLoader loader) { List elements = _getElements(context, _finder, _filters); if (_instanceType.simpleName != #PageLoaderElement) { - elements = elements.map( - (element) => loader._getInstance(_instanceType, element)).toList(); + elements = elements + .map((element) => loader._getInstance(_instanceType, element)) + .toList(); } return elements; } } class _FinderFunctionFieldInfo extends _FinderFieldInfo { - _FinderFieldInfo _impl; _FinderFunctionFieldInfo(_FinderFieldInfo impl) : super(impl._fieldName) { @@ -420,8 +409,8 @@ class _InjectedPageLoaderFieldInfo extends _FinderFieldInfo { loader; } -List _getElements(PageLoaderElement context, Finder finder, - List filters) { +List _getElements( + PageLoaderElement context, Finder finder, List filters) { List elements = finder.findElements(context); for (var filter in filters) { elements = filter.filter(elements); @@ -440,9 +429,8 @@ PageLoaderElement _getElement(PageLoaderElement context, Finder finder, return null; } if (elements.length > 1) { - throw new PageLoaderException( - 'Found ${elements.length} elements for ' - 'finder: $finder and filters: $filters'); + throw new PageLoaderException('Found ${elements.length} elements for ' + 'finder: $finder and filters: $filters'); } return elements.first; } diff --git a/dart/lib/webdriver.dart b/dart/lib/webdriver.dart index 9a54d135..df36f7c3 100644 --- a/dart/lib/webdriver.dart +++ b/dart/lib/webdriver.dart @@ -34,12 +34,11 @@ class WebDriverPageLoader extends BasePageLoader { @override final _WebDriverMouse mouse; - WebDriverPageLoader(wd.SearchContext globalContext, {this.useShadowRoot: - true}) + WebDriverPageLoader(wd.SearchContext globalContext, + {this.useShadowRoot: true}) : super(const _IOClock()), this.mouse = new _WebDriverMouse(globalContext.driver) { this._globalContext = new WebDriverPageLoaderElement(globalContext, this); - } @override @@ -59,7 +58,6 @@ class WebDriverPageLoader extends BasePageLoader { } class _WebDriverMouse implements PageLoaderMouse { - final wd.WebDriver driver; _WebDriverMouse(this.driver); @@ -76,9 +74,7 @@ class _WebDriverMouse implements PageLoaderMouse { @override void moveTo(_WebElementPageLoaderElement element, int xOffset, int yOffset) { driver.mouse.moveTo( - element: element.context, - xOffset: xOffset, - yOffset: yOffset); + element: element.context, xOffset: xOffset, yOffset: yOffset); } @override @@ -90,8 +86,8 @@ class _WebDriverMouse implements PageLoaderMouse { } } - void _fireEvent(_WebElementPageLoaderElement eventTarget, String type, - int button) { + void _fireEvent( + _WebElementPageLoaderElement eventTarget, String type, int button) { driver.execute( "arguments[0].dispatchEvent(new MouseEvent(arguments[1], {'button' : arguments[2]}));", [eventTarget.context, type, button]); @@ -112,8 +108,8 @@ abstract class WebDriverPageLoaderElement implements PageLoaderElement { @override final WebDriverPageLoader loader; - factory WebDriverPageLoaderElement(wd.SearchContext context, - WebDriverPageLoader loader) { + factory WebDriverPageLoaderElement( + wd.SearchContext context, WebDriverPageLoader loader) { if (context is wd.WebDriver) { return new _WebDriverPageLoaderElement(context, loader); } else if (context is wd.WebElement) { @@ -135,11 +131,10 @@ abstract class WebDriverPageLoaderElement implements PageLoaderElement { int get hashCode => context.hashCode; @override - bool operator ==(Object other) => - other != null && - other.runtimeType == runtimeType && - (other as WebDriverPageLoaderElement).context == context && - (other as WebDriverPageLoaderElement).loader == loader; + bool operator ==(Object other) => other != null && + other.runtimeType == runtimeType && + (other as WebDriverPageLoaderElement).context == context && + (other as WebDriverPageLoaderElement).loader == loader; @override String toString() => '$runtimeType<${context.toString()}>'; @@ -151,8 +146,8 @@ class _WebElementPageLoaderElement extends WebDriverPageLoaderElement { final PageLoaderAttributes computedStyle; final PageLoaderAttributes style; - _WebElementPageLoaderElement(wd.WebElement _context, - WebDriverPageLoader loader) + _WebElementPageLoaderElement( + wd.WebElement _context, WebDriverPageLoader loader) : super._(loader), this.context = _context, this.attributes = new _ElementAttributes(_context), @@ -172,8 +167,9 @@ class _WebElementPageLoaderElement extends WebDriverPageLoaderElement { String get name => context.name; @override - String get innerText => - context.driver.execute('return arguments[0].textContent;', [context]).trim(); + String get innerText => context.driver + .execute('return arguments[0].textContent;', [context]) + .trim(); @override String get visibleText => context.text; @@ -261,8 +257,7 @@ class _ShadowRootPageLoaderElement extends WebDriverPageLoaderElement { dynamic _execute(String script) { return context.driver.execute( - 'return arguments[0].shadowRoot$script;', - [context]); + 'return arguments[0].shadowRoot$script;', [context]); } // Overrides to make Analyzer happy. @@ -299,10 +294,10 @@ class _ElementComputedStyle extends PageLoaderAttributes { _ElementComputedStyle(this._node); @override - String operator [](String name) => - _node.driver.execute( - 'return window.getComputedStyle(arguments[0]).${_cssPropName(name)}', - [_node]); + String operator [](String name) => _node.driver.execute( + 'return window.getComputedStyle(arguments[0]).${_cssPropName(name)}', [ + _node + ]); } class _ElementStyle extends PageLoaderAttributes { @@ -311,15 +306,10 @@ class _ElementStyle extends PageLoaderAttributes { _ElementStyle(this._node); @override - String operator [](String name) => - _node.driver.execute( - 'return arguments[0].style.${_cssPropName(name)}', - [_node]); + String operator [](String name) => _node.driver.execute( + 'return arguments[0].style.${_cssPropName(name)}', [_node]); } /// Convert hyphenated-properties to camelCase. -String _cssPropName(String name) => - name.splitMapJoin( - new RegExp(r'-(\w)'), - onMatch: (m) => m.group(1).toUpperCase(), - onNonMatch: (m) => m); +String _cssPropName(String name) => name.splitMapJoin(new RegExp(r'-(\w)'), + onMatch: (m) => m.group(1).toUpperCase(), onNonMatch: (m) => m); diff --git a/dart/test/html_test.dart b/dart/test/html_test.dart index e407315c..2103c8b2 100644 --- a/dart/test/html_test.dart +++ b/dart/test/html_test.dart @@ -97,21 +97,20 @@ void main() { displayedDiv.onMouseDown.listen((evt) { displayedDiv.text = displayedDiv.text + " MouseDown: ${evt.client.x}, ${evt.client.y}; " - "${evt.screen.x}, ${evt.screen.y}"; + "${evt.screen.x}, ${evt.screen.y}"; }); displayedDiv.onMouseUp.listen((evt) { displayedDiv.text = displayedDiv.text + " MouseUp: ${evt.client.x}, ${evt.client.y}; " - "${evt.screen.x}, ${evt.screen.y}"; + "${evt.screen.x}, ${evt.screen.y}"; }); displayedDiv.onMouseMove.listen((evt) { displayedDiv.text = displayedDiv.text + " MouseMove: ${evt.client.x}, ${evt.client.y}; " - "${evt.screen.x}, ${evt.screen.y}"; + "${evt.screen.x}, ${evt.screen.y}"; }); plt.loader = new HtmlPageLoader(div); - }); group('html specific tests', () { @@ -141,8 +140,7 @@ void main() { } class NoOpNodeValidator implements html.NodeValidator { - bool allowsAttribute(html.Element element, String attributeName, - String value) => - true; + bool allowsAttribute( + html.Element element, String attributeName, String value) => true; bool allowsElement(html.Element element) => true; } diff --git a/dart/test/page_objects.dart b/dart/test/page_objects.dart index e21e8877..2ed25d5e 100644 --- a/dart/test/page_objects.dart +++ b/dart/test/page_objects.dart @@ -25,7 +25,8 @@ class PageForSimpleTest { class SubclassPage extends PageForSimpleTest {} -@Union(const [Root, const ByTagName('table')]) @IsTag('table') +@Union(const [Root, const ByTagName('table')]) +@IsTag('table') class Table { @Root PageLoaderElement root; @@ -45,13 +46,15 @@ class PageForClassAnnotationTest { } class PageForDisplayedFilteringTest { - @ById('div') @WithState.present() + @ById('div') + @WithState.present() List shouldHaveOneElement; @ById('div') List shouldBeEmpty; - @ById('div') @WithState.visible() + @ById('div') + @WithState.visible() List shouldAlsoBeEmpty; } @@ -65,7 +68,8 @@ class PageForSettersTest { PageLoader get loader => _loader; - @ById('div') @WithState.present() + @ById('div') + @WithState.present() set shouldHaveOneElement(List elements) { _shouldHaveOneElement = elements; } @@ -74,18 +78,20 @@ class PageForSettersTest { } class PageForSkipFinalTest { - - @ById('div') @WithState.present() + @ById('div') + @WithState.present() List shouldHaveOneElement; - @ById('div') @WithState.present() + @ById('div') + @WithState.present() final List shouldBeNull = null; final PageLoader loader = null; } class PageForSkipFieldsWithoutFinderTest { - @ById('div') @WithState.present() + @ById('div') + @WithState.present() List shouldHaveOneElement; @WithState.present() @@ -121,11 +127,13 @@ class PageForMultipleMatchingClassElementTest { } class PageForMultipleFinderTest { - @ById('non-existent id') @ByTagName('a-name') + @ById('non-existent id') + @ByTagName('a-name') PageLoaderElement multipleFinder; } -@ById('non-existent id') @ByTagName('a-name') +@ById('non-existent id') +@ByTagName('a-name') class PageForMultipleClassFinderTest { @Root PageLoaderElement multipleFinder; @@ -134,12 +142,14 @@ class PageForMultipleClassFinderTest { class PageForInvalidConstructorTest { PageForInvalidConstructorTest(String someArg); - @ById('div') @WithState.present() + @ById('div') + @WithState.present() List shouldHaveOneElement; } class PageForWithAttributeTest { - @ByTagName('input') @WithAttribute('type', 'checkbox') + @ByTagName('input') + @WithAttribute('type', 'checkbox') PageLoaderElement element; } @@ -148,15 +158,14 @@ class PageForAmbiguousTest { PageLoaderElement element; } -class PageForMixinTest extends PageForSimpleTest with - PageForDisplayedFilteringTest {} +class PageForMixinTest extends PageForSimpleTest + with PageForDisplayedFilteringTest {} class PageForPrivateConstructorTest extends PageForSimpleTest { PageForPrivateConstructorTest._(); } class PageForPrivateFieldsTest { - @ByTagName('table') Table _privateTable; @@ -164,7 +173,6 @@ class PageForPrivateFieldsTest { } class PageForPrivateSettersTest { - Table table; @ByTagName('table') @@ -290,7 +298,8 @@ class PageForShadowDomTest { class PageForShadowDomWithVisibleTextTest { @ByTagName('a-custom-tag') - @WithVisibleText('some') @WithVisibleText('button 1') + @WithVisibleText('some') + @WithVisibleText('button 1') PageLoaderElement button1; } @@ -301,18 +310,18 @@ class PageForChainTest { @Chain(const [const ByClass('outer-div'), const ByClass('inner-div')]) List innerDivs; - @Chain( - const [ - const ByClass('outer-div'), - const ByClass('inner-div'), - const WithClass('special')]) + @Chain(const [ + const ByClass('outer-div'), + const ByClass('inner-div'), + const WithClass('special') + ]) PageLoaderElement innerDivSpecial; - @Chain( - const [ - const ByClass('outer-div'), - const ByTagName('a-custom-tag'), - const InShadowDom(const ById('inner'))]) + @Chain(const [ + const ByClass('outer-div'), + const ByTagName('a-custom-tag'), + const InShadowDom(const ById('inner')) + ]) PageLoaderElement innerShadow; Iterable get outerDivsText => outerDivs.map((e) => e.visibleText); @@ -321,7 +330,8 @@ class PageForChainTest { class PageForShadowDomWithInnerTextTest { @ByTagName('a-custom-tag') - @WithInnerText('some') @WithInnerText('button 1') + @WithInnerText('some') + @WithInnerText('button 1') List shouldBeEmpty; @ByTagName('a-custom-tag') @@ -335,7 +345,8 @@ class PageForTextOnShadowRootTest { } class PageForAttributesTests { - @ById('div') @WithState.present() + @ById('div') + @WithState.present() PageLoaderElement divWithStyle; @ByCss('input[type=checkbox]') @@ -375,17 +386,20 @@ class PageForEqualityTest { } class PageForWithClassTest { - - @ByTagName('input') @WithClass('with-class-test') + @ByTagName('input') + @WithClass('with-class-test') PageLoaderElement element; } class PageForOptionalFunctionTest { - - @ByTagName('non-existant') @Optional @Returns(PageLoaderElement) + @ByTagName('non-existant') + @Optional + @Returns(PageLoaderElement) var shouldBeNull; - @ById('button-1') @Optional @Returns(PageLoaderElement) + @ById('button-1') + @Optional + @Returns(PageLoaderElement) var shouldBeNonNull; } @@ -395,7 +409,6 @@ class PageForMouseTest { } class PageForGlobalTest { - @ByTagName('table') PageLoaderElement table; diff --git a/dart/test/pageloader_test.dart b/dart/test/pageloader_test.dart index 4043da19..03302381 100644 --- a/dart/test/pageloader_test.dart +++ b/dart/test/pageloader_test.dart @@ -23,7 +23,6 @@ import 'package:unittest/unittest.dart'; PageLoader loader; void runTests() { - verifyRows(List rows) { expect(rows, hasLength(2)); expect(rows.first.cells, hasLength(2)); @@ -75,7 +74,6 @@ void runTests() { PageForSettersTest page = loader.getInstance(PageForSettersTest); expect(page.shouldHaveOneElement, hasLength(1)); expect(page.loader, loader); - }); test('skip finals', () { @@ -98,8 +96,7 @@ void runTests() { test('no matching class element', () { expect( - () => loader.getInstance(PageForNoMatchingClassElementTest), - throws); + () => loader.getInstance(PageForNoMatchingClassElementTest), throws); }); test('no matching but nullable element', () { @@ -110,13 +107,11 @@ void runTests() { test('multiple matching element', () { expect( - () => loader.getInstance(PageForMultipleMatchingElementTest), - throws); + () => loader.getInstance(PageForMultipleMatchingElementTest), throws); }); test('multiple matching element', () { - expect( - () => loader.getInstance(PageForMultipleMatchingClassElementTest), + expect(() => loader.getInstance(PageForMultipleMatchingClassElementTest), throws); }); @@ -141,8 +136,7 @@ void runTests() { test('WithClass', () { var page = loader.getInstance(PageForWithClassTest); expect(page.element.attributes['type'], 'checkbox'); - expect( - page.element.classes, + expect(page.element.classes, unorderedEquals(['with-class-test', 'class1', 'class2'])); }); @@ -229,7 +223,6 @@ void runTests() { expect(page.shouldBeEmpty, isEmpty); }); - test('WithVisibleText in shadow dom', () { PageForShadowDomWithVisibleTextTest page = loader.getInstance(PageForShadowDomWithVisibleTextTest); @@ -279,8 +272,7 @@ void runTests() { test('classes', () { PageForSimpleTest page = loader.getInstance(PageForSimpleTest); - expect( - page.table.root.classes, + expect(page.table.root.classes, orderedEquals(['class1', 'class2', 'class3'])); expect(page.table.rows.first.cells.first.classes, hasLength(0)); }); @@ -297,8 +289,7 @@ void runTests() { expect(page.table.root.computedStyle['color'], 'rgb(128, 0, 128)'); expect( - page.table.root.computedStyle['background-color'], - 'rgb(0, 255, 0)'); + page.table.root.computedStyle['background-color'], 'rgb(0, 255, 0)'); }); test('equals/hashCode', () { @@ -323,8 +314,8 @@ void runTests() { loader.mouse.down(0); loader.waitFor(() => page.element.visibleText, contains('MouseDown')); loader.mouse - ..moveTo(page.element, 10, 10) - ..up(0); + ..moveTo(page.element, 10, 10) + ..up(0); loader.waitFor(() => page.element.visibleText, contains('MouseUp')); }); @@ -336,8 +327,8 @@ void runTests() { loader.mouse.down(0, eventTarget: page.element); loader.waitFor(() => page.element.visibleText, contains('MouseDown')); loader.mouse - ..moveTo(page.element, 200, 200) - ..up(0, eventTarget: page.element); + ..moveTo(page.element, 200, 200) + ..up(0, eventTarget: page.element); loader.waitFor(() => page.element.visibleText, contains('MouseUp')); }); @@ -407,19 +398,15 @@ void runTests() { }); group('attributes', () { - test('style', () { var page = loader.getInstance(PageForAttributesTests); // According to the spec, red below should be returned as an // RGBA value. - expect( - page.divWithStyle.attributes['style'], + expect(page.divWithStyle.attributes['style'], 'display: none; background-color: red;'); - expect( - page.divWithStyle.attributes['STYLE'], + expect(page.divWithStyle.attributes['STYLE'], 'display: none; background-color: red;'); - expect( - page.divWithStyle.attributes['StYlE'], + expect(page.divWithStyle.attributes['StYlE'], 'display: none; background-color: red;'); }); @@ -509,7 +496,6 @@ void runTests() { }); group('typing', () { - test('typing should append', () { var page = loader.getInstance(PageForAttributesTests); expect(page.text.attributes['value'], ''); From 8520c132caeb54a9d46e174d512caf8bbbb70b6d Mon Sep 17 00:00:00 2001 From: Marc Fisher II Date: Mon, 12 Jan 2015 10:08:17 -0800 Subject: [PATCH 2/2] Format dart file with dartformat. --- dart/lib/html.dart | 109 ++++++++++++++++----------------- dart/lib/src/annotations.dart | 8 +-- dart/lib/src/core.dart | 48 ++++++--------- dart/lib/webdriver.dart | 60 ++++++++---------- dart/test/html_test.dart | 12 ++-- dart/test/page_objects.dart | 83 ++++++++++++++----------- dart/test/pageloader_test.dart | 40 ++++-------- 7 files changed, 165 insertions(+), 195 deletions(-) diff --git a/dart/lib/html.dart b/dart/lib/html.dart index d566b689..7ffd9eff 100644 --- a/dart/lib/html.dart +++ b/dart/lib/html.dart @@ -58,8 +58,7 @@ class HtmlPageLoader extends BasePageLoader { return new HtmlPageLoader._(globalContext, clock); } - HtmlPageLoader._(Node globalContext, Clock clock) - : super(clock) { + HtmlPageLoader._(Node globalContext, Clock clock) : super(clock) { this._globalContext = new HtmlPageLoaderElement(globalContext, this); this._mouse = new _HtmlMouse(this); } @@ -80,7 +79,6 @@ class HtmlPageLoader extends BasePageLoader { } class _HtmlMouse implements PageLoaderMouse { - final HtmlPageLoader loader; int clientX = 0; @@ -114,12 +112,13 @@ class _HtmlMouse implements PageLoaderMouse { int get _borderWidth => (window.outerWidth - window.innerWidth) ~/ 2; int get screenX => window.screenLeft + _borderWidth + clientX; int get screenY => window.screenTop + window.outerHeight - - window.innerHeight - _borderWidth + clientY; + window.innerHeight - + _borderWidth + + clientY; void dispatchEvent(String type, _ElementPageLoaderElement eventTarget, [int button = 0]) { - var event = new MouseEvent( - type, + var event = new MouseEvent(type, button: button, clientX: clientX, clientY: clientY, @@ -179,11 +178,10 @@ abstract class HtmlPageLoaderElement implements PageLoaderElement { int get hashCode => node.hashCode; @override - bool operator ==(other) => - other != null && - other.runtimeType == runtimeType && - other.node == node && - other.loader == loader; + bool operator ==(other) => other != null && + other.runtimeType == runtimeType && + other.node == node && + other.loader == loader; @override String toString() => '$runtimeType<${node.toString()}>'; @@ -197,8 +195,8 @@ abstract class HtmlPageLoaderElement implements PageLoaderElement { // https://code.google.com/p/dart/issues/detail?id=13902 void _fireKeyPressEvents(Element element, String keys) { for (int charCode in keys.codeUnits) { - element.dispatchEvent( - new KeyEvent('keypress', charCode: charCode).wrapped); + element + .dispatchEvent(new KeyEvent('keypress', charCode: charCode).wrapped); } } } @@ -333,47 +331,48 @@ class _DocumentPageLoaderElement extends HtmlPageLoaderElement { class _ElementAttributes extends PageLoaderAttributes { static const _BOOLEAN_ATTRIBUTES = const [ - 'async', - 'autofocus', - 'autoplay', - 'checked', - 'compact', - 'complete', - 'controls', - 'declare', - 'defaultchecked', - 'defaultselected', - 'defer', - 'disabled', - 'draggable', - 'ended', - 'formnovalidate', - 'hidden', - 'indeterminate', - 'iscontenteditable', - 'ismap', - 'itemscope', - 'loop', - 'multiple', - 'muted', - 'nohref', - 'noresize', - 'noshade', - 'novalidate', - 'nowrap', - 'open', - 'paused', - 'pubdate', - 'readonly', - 'required', - 'reversed', - 'scoped', - 'seamless', - 'seeking', - 'selected', - 'spellcheck', - 'truespeed', - 'willvalidate']; + 'async', + 'autofocus', + 'autoplay', + 'checked', + 'compact', + 'complete', + 'controls', + 'declare', + 'defaultchecked', + 'defaultselected', + 'defer', + 'disabled', + 'draggable', + 'ended', + 'formnovalidate', + 'hidden', + 'indeterminate', + 'iscontenteditable', + 'ismap', + 'itemscope', + 'loop', + 'multiple', + 'muted', + 'nohref', + 'noresize', + 'noshade', + 'novalidate', + 'nowrap', + 'open', + 'paused', + 'pubdate', + 'readonly', + 'required', + 'reversed', + 'scoped', + 'seamless', + 'seeking', + 'selected', + 'spellcheck', + 'truespeed', + 'willvalidate' + ]; final Element _node; @@ -434,7 +433,7 @@ class _ElementAttributes extends PageLoaderAttributes { try { // 7.1 result = reflect(_node).getField(new Symbol(name)).reflectee; - } catch (e) { /* 7.2 - 7.3 ignore and default to attribute value or null*/ } + } catch (e) {/* 7.2 - 7.3 ignore and default to attribute value or null*/} if (result is bool) { return result ? 'true' : null; diff --git a/dart/lib/src/annotations.dart b/dart/lib/src/annotations.dart index cdc719fa..484f0fab 100644 --- a/dart/lib/src/annotations.dart +++ b/dart/lib/src/annotations.dart @@ -96,13 +96,11 @@ class Returns { } class ReturnsList extends Returns { - const ReturnsList(Type type) : super(type); } /// Filters element based on visibility. class WithState extends ElementFilter implements HasFilterFinderOptions { - final bool _displayed; const WithState._(this._displayed); @@ -180,7 +178,6 @@ class _Root implements Finder, HasFilterFinderOptions { /// Keeps only [PageLoaderElement]s that have the given attribute with the /// given value. class WithAttribute extends ElementFilter { - final String name; final String value; @@ -194,7 +191,6 @@ class WithAttribute extends ElementFilter { /// Keeps only [PageLoaderElement]s that correspond to the given tag. class IsTag extends ElementFilter { - final String tagName; const IsTag(this.tagName); @@ -316,8 +312,8 @@ class Global implements Finder { @override List findElements(PageLoaderElement context) => - annotation.findElements(context.loader.globalContext); + annotation.findElements(context.loader.globalContext); @override String toString() => '@Global($annotation)'; -} \ No newline at end of file +} diff --git a/dart/lib/src/core.dart b/dart/lib/src/core.dart index 982573c8..5668e355 100644 --- a/dart/lib/src/core.dart +++ b/dart/lib/src/core.dart @@ -53,13 +53,13 @@ abstract class BasePageLoader implements PageLoader { new _ClassInfo(type).getInstance(context, this); @override - waitForValue(condition(), {Duration timeout: _DEFAULT_WAIT, Duration interval: - _DEFAULT_INTERVAL}) => + waitForValue(condition(), {Duration timeout: _DEFAULT_WAIT, + Duration interval: _DEFAULT_INTERVAL}) => waitFor(condition, isNotNull, timeout: timeout, interval: interval); @override - waitFor(condition(), Matcher matcher, {Duration timeout: _DEFAULT_WAIT, - Duration interval: _DEFAULT_INTERVAL}) { + waitFor(condition(), Matcher matcher, + {Duration timeout: _DEFAULT_WAIT, Duration interval: _DEFAULT_INTERVAL}) { var endTime = clock.now.add(timeout); while (true) { try { @@ -87,9 +87,8 @@ class _Lazy implements Lazy { } class _ClassInfo { - - static final Map _classInfoCache = {}; + static final Map _classInfoCache = + {}; final ClassMirror _class; final List<_FieldInfo> _fields; @@ -119,11 +118,7 @@ class _ClassInfo { } return new _ClassInfo._( - type, - _fieldInfos(type), - finder, - filters, - finderIsOptional); + type, _fieldInfos(type), finder, filters, finderIsOptional); }); _ClassInfo._(this._class, this._fields, this._finder, this._filters, @@ -213,7 +208,6 @@ class _ClassInfo { } abstract class _FieldInfo { - factory _FieldInfo(DeclarationMirror field) { var finder; var filters = new List(); @@ -336,7 +330,6 @@ abstract class _FieldInfo { } abstract class _FinderFieldInfo implements _FieldInfo { - final Symbol _fieldName; _FinderFieldInfo(this._fieldName); @@ -356,21 +349,18 @@ abstract class _FinderFieldInfo implements _FieldInfo { } class _FinderSingleFieldInfo extends _FinderFieldInfo { - final Finder _finder; final List _filters; final ClassMirror _instanceType; final bool _isOptional; _FinderSingleFieldInfo(Symbol fieldName, this._finder, this._filters, - this._instanceType, this._isOptional) - : super(fieldName); + this._instanceType, this._isOptional) : super(fieldName); @override calculateFieldValue(PageLoaderElement context, BasePageLoader loader) { var element = _getElement(context, _finder, _filters, _isOptional); - if (_instanceType.simpleName != #PageLoaderElement && - element != null) { + if (_instanceType.simpleName != #PageLoaderElement && element != null) { element = loader._getInstance(_instanceType, element); } return element; @@ -378,28 +368,27 @@ class _FinderSingleFieldInfo extends _FinderFieldInfo { } class _FinderListFieldInfo extends _FinderFieldInfo { - final Finder _finder; final List _filters; final ClassMirror _instanceType; - _FinderListFieldInfo(Symbol fieldName, this._finder, this._filters, - this._instanceType) + _FinderListFieldInfo( + Symbol fieldName, this._finder, this._filters, this._instanceType) : super(fieldName); @override calculateFieldValue(PageLoaderElement context, BasePageLoader loader) { List elements = _getElements(context, _finder, _filters); if (_instanceType.simpleName != #PageLoaderElement) { - elements = elements.map( - (element) => loader._getInstance(_instanceType, element)).toList(); + elements = elements + .map((element) => loader._getInstance(_instanceType, element)) + .toList(); } return elements; } } class _FinderFunctionFieldInfo extends _FinderFieldInfo { - _FinderFieldInfo _impl; _FinderFunctionFieldInfo(_FinderFieldInfo impl) : super(impl._fieldName) { @@ -420,8 +409,8 @@ class _InjectedPageLoaderFieldInfo extends _FinderFieldInfo { loader; } -List _getElements(PageLoaderElement context, Finder finder, - List filters) { +List _getElements( + PageLoaderElement context, Finder finder, List filters) { List elements = finder.findElements(context); for (var filter in filters) { elements = filter.filter(elements); @@ -440,9 +429,8 @@ PageLoaderElement _getElement(PageLoaderElement context, Finder finder, return null; } if (elements.length > 1) { - throw new PageLoaderException( - 'Found ${elements.length} elements for ' - 'finder: $finder and filters: $filters'); + throw new PageLoaderException('Found ${elements.length} elements for ' + 'finder: $finder and filters: $filters'); } return elements.first; } diff --git a/dart/lib/webdriver.dart b/dart/lib/webdriver.dart index 9a54d135..df36f7c3 100644 --- a/dart/lib/webdriver.dart +++ b/dart/lib/webdriver.dart @@ -34,12 +34,11 @@ class WebDriverPageLoader extends BasePageLoader { @override final _WebDriverMouse mouse; - WebDriverPageLoader(wd.SearchContext globalContext, {this.useShadowRoot: - true}) + WebDriverPageLoader(wd.SearchContext globalContext, + {this.useShadowRoot: true}) : super(const _IOClock()), this.mouse = new _WebDriverMouse(globalContext.driver) { this._globalContext = new WebDriverPageLoaderElement(globalContext, this); - } @override @@ -59,7 +58,6 @@ class WebDriverPageLoader extends BasePageLoader { } class _WebDriverMouse implements PageLoaderMouse { - final wd.WebDriver driver; _WebDriverMouse(this.driver); @@ -76,9 +74,7 @@ class _WebDriverMouse implements PageLoaderMouse { @override void moveTo(_WebElementPageLoaderElement element, int xOffset, int yOffset) { driver.mouse.moveTo( - element: element.context, - xOffset: xOffset, - yOffset: yOffset); + element: element.context, xOffset: xOffset, yOffset: yOffset); } @override @@ -90,8 +86,8 @@ class _WebDriverMouse implements PageLoaderMouse { } } - void _fireEvent(_WebElementPageLoaderElement eventTarget, String type, - int button) { + void _fireEvent( + _WebElementPageLoaderElement eventTarget, String type, int button) { driver.execute( "arguments[0].dispatchEvent(new MouseEvent(arguments[1], {'button' : arguments[2]}));", [eventTarget.context, type, button]); @@ -112,8 +108,8 @@ abstract class WebDriverPageLoaderElement implements PageLoaderElement { @override final WebDriverPageLoader loader; - factory WebDriverPageLoaderElement(wd.SearchContext context, - WebDriverPageLoader loader) { + factory WebDriverPageLoaderElement( + wd.SearchContext context, WebDriverPageLoader loader) { if (context is wd.WebDriver) { return new _WebDriverPageLoaderElement(context, loader); } else if (context is wd.WebElement) { @@ -135,11 +131,10 @@ abstract class WebDriverPageLoaderElement implements PageLoaderElement { int get hashCode => context.hashCode; @override - bool operator ==(Object other) => - other != null && - other.runtimeType == runtimeType && - (other as WebDriverPageLoaderElement).context == context && - (other as WebDriverPageLoaderElement).loader == loader; + bool operator ==(Object other) => other != null && + other.runtimeType == runtimeType && + (other as WebDriverPageLoaderElement).context == context && + (other as WebDriverPageLoaderElement).loader == loader; @override String toString() => '$runtimeType<${context.toString()}>'; @@ -151,8 +146,8 @@ class _WebElementPageLoaderElement extends WebDriverPageLoaderElement { final PageLoaderAttributes computedStyle; final PageLoaderAttributes style; - _WebElementPageLoaderElement(wd.WebElement _context, - WebDriverPageLoader loader) + _WebElementPageLoaderElement( + wd.WebElement _context, WebDriverPageLoader loader) : super._(loader), this.context = _context, this.attributes = new _ElementAttributes(_context), @@ -172,8 +167,9 @@ class _WebElementPageLoaderElement extends WebDriverPageLoaderElement { String get name => context.name; @override - String get innerText => - context.driver.execute('return arguments[0].textContent;', [context]).trim(); + String get innerText => context.driver + .execute('return arguments[0].textContent;', [context]) + .trim(); @override String get visibleText => context.text; @@ -261,8 +257,7 @@ class _ShadowRootPageLoaderElement extends WebDriverPageLoaderElement { dynamic _execute(String script) { return context.driver.execute( - 'return arguments[0].shadowRoot$script;', - [context]); + 'return arguments[0].shadowRoot$script;', [context]); } // Overrides to make Analyzer happy. @@ -299,10 +294,10 @@ class _ElementComputedStyle extends PageLoaderAttributes { _ElementComputedStyle(this._node); @override - String operator [](String name) => - _node.driver.execute( - 'return window.getComputedStyle(arguments[0]).${_cssPropName(name)}', - [_node]); + String operator [](String name) => _node.driver.execute( + 'return window.getComputedStyle(arguments[0]).${_cssPropName(name)}', [ + _node + ]); } class _ElementStyle extends PageLoaderAttributes { @@ -311,15 +306,10 @@ class _ElementStyle extends PageLoaderAttributes { _ElementStyle(this._node); @override - String operator [](String name) => - _node.driver.execute( - 'return arguments[0].style.${_cssPropName(name)}', - [_node]); + String operator [](String name) => _node.driver.execute( + 'return arguments[0].style.${_cssPropName(name)}', [_node]); } /// Convert hyphenated-properties to camelCase. -String _cssPropName(String name) => - name.splitMapJoin( - new RegExp(r'-(\w)'), - onMatch: (m) => m.group(1).toUpperCase(), - onNonMatch: (m) => m); +String _cssPropName(String name) => name.splitMapJoin(new RegExp(r'-(\w)'), + onMatch: (m) => m.group(1).toUpperCase(), onNonMatch: (m) => m); diff --git a/dart/test/html_test.dart b/dart/test/html_test.dart index e407315c..2103c8b2 100644 --- a/dart/test/html_test.dart +++ b/dart/test/html_test.dart @@ -97,21 +97,20 @@ void main() { displayedDiv.onMouseDown.listen((evt) { displayedDiv.text = displayedDiv.text + " MouseDown: ${evt.client.x}, ${evt.client.y}; " - "${evt.screen.x}, ${evt.screen.y}"; + "${evt.screen.x}, ${evt.screen.y}"; }); displayedDiv.onMouseUp.listen((evt) { displayedDiv.text = displayedDiv.text + " MouseUp: ${evt.client.x}, ${evt.client.y}; " - "${evt.screen.x}, ${evt.screen.y}"; + "${evt.screen.x}, ${evt.screen.y}"; }); displayedDiv.onMouseMove.listen((evt) { displayedDiv.text = displayedDiv.text + " MouseMove: ${evt.client.x}, ${evt.client.y}; " - "${evt.screen.x}, ${evt.screen.y}"; + "${evt.screen.x}, ${evt.screen.y}"; }); plt.loader = new HtmlPageLoader(div); - }); group('html specific tests', () { @@ -141,8 +140,7 @@ void main() { } class NoOpNodeValidator implements html.NodeValidator { - bool allowsAttribute(html.Element element, String attributeName, - String value) => - true; + bool allowsAttribute( + html.Element element, String attributeName, String value) => true; bool allowsElement(html.Element element) => true; } diff --git a/dart/test/page_objects.dart b/dart/test/page_objects.dart index e21e8877..2ed25d5e 100644 --- a/dart/test/page_objects.dart +++ b/dart/test/page_objects.dart @@ -25,7 +25,8 @@ class PageForSimpleTest { class SubclassPage extends PageForSimpleTest {} -@Union(const [Root, const ByTagName('table')]) @IsTag('table') +@Union(const [Root, const ByTagName('table')]) +@IsTag('table') class Table { @Root PageLoaderElement root; @@ -45,13 +46,15 @@ class PageForClassAnnotationTest { } class PageForDisplayedFilteringTest { - @ById('div') @WithState.present() + @ById('div') + @WithState.present() List shouldHaveOneElement; @ById('div') List shouldBeEmpty; - @ById('div') @WithState.visible() + @ById('div') + @WithState.visible() List shouldAlsoBeEmpty; } @@ -65,7 +68,8 @@ class PageForSettersTest { PageLoader get loader => _loader; - @ById('div') @WithState.present() + @ById('div') + @WithState.present() set shouldHaveOneElement(List elements) { _shouldHaveOneElement = elements; } @@ -74,18 +78,20 @@ class PageForSettersTest { } class PageForSkipFinalTest { - - @ById('div') @WithState.present() + @ById('div') + @WithState.present() List shouldHaveOneElement; - @ById('div') @WithState.present() + @ById('div') + @WithState.present() final List shouldBeNull = null; final PageLoader loader = null; } class PageForSkipFieldsWithoutFinderTest { - @ById('div') @WithState.present() + @ById('div') + @WithState.present() List shouldHaveOneElement; @WithState.present() @@ -121,11 +127,13 @@ class PageForMultipleMatchingClassElementTest { } class PageForMultipleFinderTest { - @ById('non-existent id') @ByTagName('a-name') + @ById('non-existent id') + @ByTagName('a-name') PageLoaderElement multipleFinder; } -@ById('non-existent id') @ByTagName('a-name') +@ById('non-existent id') +@ByTagName('a-name') class PageForMultipleClassFinderTest { @Root PageLoaderElement multipleFinder; @@ -134,12 +142,14 @@ class PageForMultipleClassFinderTest { class PageForInvalidConstructorTest { PageForInvalidConstructorTest(String someArg); - @ById('div') @WithState.present() + @ById('div') + @WithState.present() List shouldHaveOneElement; } class PageForWithAttributeTest { - @ByTagName('input') @WithAttribute('type', 'checkbox') + @ByTagName('input') + @WithAttribute('type', 'checkbox') PageLoaderElement element; } @@ -148,15 +158,14 @@ class PageForAmbiguousTest { PageLoaderElement element; } -class PageForMixinTest extends PageForSimpleTest with - PageForDisplayedFilteringTest {} +class PageForMixinTest extends PageForSimpleTest + with PageForDisplayedFilteringTest {} class PageForPrivateConstructorTest extends PageForSimpleTest { PageForPrivateConstructorTest._(); } class PageForPrivateFieldsTest { - @ByTagName('table') Table _privateTable; @@ -164,7 +173,6 @@ class PageForPrivateFieldsTest { } class PageForPrivateSettersTest { - Table table; @ByTagName('table') @@ -290,7 +298,8 @@ class PageForShadowDomTest { class PageForShadowDomWithVisibleTextTest { @ByTagName('a-custom-tag') - @WithVisibleText('some') @WithVisibleText('button 1') + @WithVisibleText('some') + @WithVisibleText('button 1') PageLoaderElement button1; } @@ -301,18 +310,18 @@ class PageForChainTest { @Chain(const [const ByClass('outer-div'), const ByClass('inner-div')]) List innerDivs; - @Chain( - const [ - const ByClass('outer-div'), - const ByClass('inner-div'), - const WithClass('special')]) + @Chain(const [ + const ByClass('outer-div'), + const ByClass('inner-div'), + const WithClass('special') + ]) PageLoaderElement innerDivSpecial; - @Chain( - const [ - const ByClass('outer-div'), - const ByTagName('a-custom-tag'), - const InShadowDom(const ById('inner'))]) + @Chain(const [ + const ByClass('outer-div'), + const ByTagName('a-custom-tag'), + const InShadowDom(const ById('inner')) + ]) PageLoaderElement innerShadow; Iterable get outerDivsText => outerDivs.map((e) => e.visibleText); @@ -321,7 +330,8 @@ class PageForChainTest { class PageForShadowDomWithInnerTextTest { @ByTagName('a-custom-tag') - @WithInnerText('some') @WithInnerText('button 1') + @WithInnerText('some') + @WithInnerText('button 1') List shouldBeEmpty; @ByTagName('a-custom-tag') @@ -335,7 +345,8 @@ class PageForTextOnShadowRootTest { } class PageForAttributesTests { - @ById('div') @WithState.present() + @ById('div') + @WithState.present() PageLoaderElement divWithStyle; @ByCss('input[type=checkbox]') @@ -375,17 +386,20 @@ class PageForEqualityTest { } class PageForWithClassTest { - - @ByTagName('input') @WithClass('with-class-test') + @ByTagName('input') + @WithClass('with-class-test') PageLoaderElement element; } class PageForOptionalFunctionTest { - - @ByTagName('non-existant') @Optional @Returns(PageLoaderElement) + @ByTagName('non-existant') + @Optional + @Returns(PageLoaderElement) var shouldBeNull; - @ById('button-1') @Optional @Returns(PageLoaderElement) + @ById('button-1') + @Optional + @Returns(PageLoaderElement) var shouldBeNonNull; } @@ -395,7 +409,6 @@ class PageForMouseTest { } class PageForGlobalTest { - @ByTagName('table') PageLoaderElement table; diff --git a/dart/test/pageloader_test.dart b/dart/test/pageloader_test.dart index 4043da19..03302381 100644 --- a/dart/test/pageloader_test.dart +++ b/dart/test/pageloader_test.dart @@ -23,7 +23,6 @@ import 'package:unittest/unittest.dart'; PageLoader loader; void runTests() { - verifyRows(List rows) { expect(rows, hasLength(2)); expect(rows.first.cells, hasLength(2)); @@ -75,7 +74,6 @@ void runTests() { PageForSettersTest page = loader.getInstance(PageForSettersTest); expect(page.shouldHaveOneElement, hasLength(1)); expect(page.loader, loader); - }); test('skip finals', () { @@ -98,8 +96,7 @@ void runTests() { test('no matching class element', () { expect( - () => loader.getInstance(PageForNoMatchingClassElementTest), - throws); + () => loader.getInstance(PageForNoMatchingClassElementTest), throws); }); test('no matching but nullable element', () { @@ -110,13 +107,11 @@ void runTests() { test('multiple matching element', () { expect( - () => loader.getInstance(PageForMultipleMatchingElementTest), - throws); + () => loader.getInstance(PageForMultipleMatchingElementTest), throws); }); test('multiple matching element', () { - expect( - () => loader.getInstance(PageForMultipleMatchingClassElementTest), + expect(() => loader.getInstance(PageForMultipleMatchingClassElementTest), throws); }); @@ -141,8 +136,7 @@ void runTests() { test('WithClass', () { var page = loader.getInstance(PageForWithClassTest); expect(page.element.attributes['type'], 'checkbox'); - expect( - page.element.classes, + expect(page.element.classes, unorderedEquals(['with-class-test', 'class1', 'class2'])); }); @@ -229,7 +223,6 @@ void runTests() { expect(page.shouldBeEmpty, isEmpty); }); - test('WithVisibleText in shadow dom', () { PageForShadowDomWithVisibleTextTest page = loader.getInstance(PageForShadowDomWithVisibleTextTest); @@ -279,8 +272,7 @@ void runTests() { test('classes', () { PageForSimpleTest page = loader.getInstance(PageForSimpleTest); - expect( - page.table.root.classes, + expect(page.table.root.classes, orderedEquals(['class1', 'class2', 'class3'])); expect(page.table.rows.first.cells.first.classes, hasLength(0)); }); @@ -297,8 +289,7 @@ void runTests() { expect(page.table.root.computedStyle['color'], 'rgb(128, 0, 128)'); expect( - page.table.root.computedStyle['background-color'], - 'rgb(0, 255, 0)'); + page.table.root.computedStyle['background-color'], 'rgb(0, 255, 0)'); }); test('equals/hashCode', () { @@ -323,8 +314,8 @@ void runTests() { loader.mouse.down(0); loader.waitFor(() => page.element.visibleText, contains('MouseDown')); loader.mouse - ..moveTo(page.element, 10, 10) - ..up(0); + ..moveTo(page.element, 10, 10) + ..up(0); loader.waitFor(() => page.element.visibleText, contains('MouseUp')); }); @@ -336,8 +327,8 @@ void runTests() { loader.mouse.down(0, eventTarget: page.element); loader.waitFor(() => page.element.visibleText, contains('MouseDown')); loader.mouse - ..moveTo(page.element, 200, 200) - ..up(0, eventTarget: page.element); + ..moveTo(page.element, 200, 200) + ..up(0, eventTarget: page.element); loader.waitFor(() => page.element.visibleText, contains('MouseUp')); }); @@ -407,19 +398,15 @@ void runTests() { }); group('attributes', () { - test('style', () { var page = loader.getInstance(PageForAttributesTests); // According to the spec, red below should be returned as an // RGBA value. - expect( - page.divWithStyle.attributes['style'], + expect(page.divWithStyle.attributes['style'], 'display: none; background-color: red;'); - expect( - page.divWithStyle.attributes['STYLE'], + expect(page.divWithStyle.attributes['STYLE'], 'display: none; background-color: red;'); - expect( - page.divWithStyle.attributes['StYlE'], + expect(page.divWithStyle.attributes['StYlE'], 'display: none; background-color: red;'); }); @@ -509,7 +496,6 @@ void runTests() { }); group('typing', () { - test('typing should append', () { var page = loader.getInstance(PageForAttributesTests); expect(page.text.attributes['value'], '');