diff --git a/pubspec.yaml b/pubspec.yaml index 181312f29..1c6b0f35e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: logging: ">=0.11.3+1 <1.0.0" meta: "^1.0.4" path: "^1.4.1" - react: "^3.4.0" + react: "^3.4.1" source_span: "^1.4.0" transformer_utils: "^0.1.1" w_flux: "^2.7.1" diff --git a/test/over_react/component/dom_components_test.dart b/test/over_react/component/dom_components_test.dart index 338a9733b..e93445fdf 100644 --- a/test/over_react/component/dom_components_test.dart +++ b/test/over_react/component/dom_components_test.dart @@ -25,19 +25,51 @@ import 'package:over_react/over_react.dart'; import 'package:react/react_client.dart'; import 'package:test/test.dart'; - main() { group('Dom component:', () { - ClassMirror domClassMirror = reflectClass(Dom); + const expectedStaticMethods = const[ + // DOM + #a, #abbr, #address, #area, #article, #aside, #audio, #b, #base, #bdi, #bdo, #big, #blockquote, #body, #br, + #button, #canvas, #caption, #cite, #code, #col, #colgroup, #data, #datalist, #dd, #del, #details, #dfn, #dialog, + #div, #dl, #dt, #em, #embed, #fieldset, #figcaption, #figure, #footer, #form, #h1, #h2, #h3, #h4, #h5, #h6, + #head, #header, #hr, #html, #i, #iframe, #img, #input, #ins, #kbd, #keygen, #label, #legend, #li, #link, #main, + #map, #mark, #menu, #menuitem, #meta, #meter, #nav, #noscript, #object, #ol, #optgroup, #option, #output, #p, + #param, #picture, #pre, #progress, #q, #rp, #rt, #ruby, #s, #samp, #script, #section, #select, #small, #source, + #span, #strong, #style, #sub, #summary, #sup, #table, #tbody, #td, #textarea, #tfoot, #th, #thead, #time, + #title, #tr, #track, #u, #ul, #variable, #video, #wbr, + // SVG + #svgA, #altGlyph, #altGlyphDef, #altGlyphItem, #animate, #animateColor, #animateMotion, #animateTransform, + #svgAudio, #svgCanvas, #circle, #clipPath, #colorProfile, #cursor, #defs, #desc, #discard, #ellipse, #feBlend, + #feColorMatrix, #feComponentTransfer, #feComposite, #feConvolveMatrix, #feDiffuseLighting, #feDisplacementMap, + #feDistantLight, #feDropShadow, #feFlood, #feFuncA, #feFuncB, #feFuncG, #feFuncR, #feGaussianBlur, #feImage, + #feMerge, #feMergeNode, #feMorphology, #feOffset, #fePointLight, #feSpecularLighting, #feSpotLight, #feTile, + #feTurbulence, #filter, #font, #fontFace, #fontFaceFormat, #fontFaceName, #fontFaceSrc, #fontFaceUri, + #foreignObject, #g, #glyph, #glyphRef, #hatch, #hatchpath, #hkern, #svgIframe, #image, #line, #linearGradient, + #marker, #mask, #mesh, #meshgradient, #meshpatch, #meshrow, #metadata, #missingGlyph, #mpath, #path, #pattern, + #polygon, #polyline, #radialGradient, #rect, #svgScript, #svgSet, #solidcolor, #stop, #svgStyle, #svg, + #svgSwitch, #symbol, #text, #textPath, #svgTitle, #tref, #tspan, #unknown, #use, #svgVideo, #view, #vkern, + ]; - List methods = domClassMirror.staticMembers.values.toList(); + List methods = []; + ClassMirror domClassMirror; setUpAll(() { - expect(methods, isNotEmpty, reason: 'should have properly reflected the static members.'); + domClassMirror = reflectClass(Dom); + + // staticMembers is not implemented for the DDC and will throw is this test is loaded even if it's not run. + try { + methods = domClassMirror.staticMembers.values.map((m) => m.simpleName).toList(); + + expect(methods, isNotEmpty, reason: 'should have properly reflected the static members.'); + } catch(e) {} + + if (methods.isNotEmpty) { + expect(methods, unorderedEquals(expectedStaticMethods), reason: '`expectedStaticMethods` needs to be updated'); + } }); - for (var element in methods) { - String name = MirrorSystem.getName(element.simpleName); + for (var element in expectedStaticMethods) { + String name = MirrorSystem.getName(element); String expectedTagName = name; if (expectedTagName == 'variable') expectedTagName = 'var'; if (expectedTagName == 'svgSet') expectedTagName = 'set'; @@ -52,7 +84,7 @@ main() { if (expectedTagName.startsWith(new RegExp('svg.'))) expectedTagName = expectedTagName.substring(3); test('Dom.$name generates the correct type', () { - DomProps builder = domClassMirror.invoke(element.simpleName, []).reflectee; + DomProps builder = domClassMirror.invoke(element, []).reflectee; ReactElement component = builder(); expect(component.type, equalsIgnoringCase(expectedTagName)); }); diff --git a/test/over_react/component/resize_sensor_test.dart b/test/over_react/component/resize_sensor_test.dart index 940b7968d..126730d08 100644 --- a/test/over_react/component/resize_sensor_test.dart +++ b/test/over_react/component/resize_sensor_test.dart @@ -437,6 +437,9 @@ void main() { group('common component functionality:', () { commonComponentTests(ResizeSensor); - }); + }, + // Mirrors don't work in the DDC. + tags: 'no-ddc' + ); }); } diff --git a/test/over_react/component_declaration/component_base_test.dart b/test/over_react/component_declaration/component_base_test.dart index 14da990d3..b4940ce65 100644 --- a/test/over_react/component_declaration/component_base_test.dart +++ b/test/over_react/component_declaration/component_base_test.dart @@ -92,7 +92,7 @@ main() { test('a single child is passed in', () { var child = 'Only child'; var renderedNode = renderAndGetDom(Dom.div()(child)); - List children = renderedNode.childNodes.where((node) => node.nodeType != Node.COMMENT_NODE).toList(); + var children = new List.from(renderedNode.childNodes.where((node) => node.nodeType != Node.COMMENT_NODE)); expect(children.length, equals(1)); expect(children[0].data, equals(child)); diff --git a/test/over_react/component_declaration/transformer_integration_tests/component_integration_test.dart b/test/over_react/component_declaration/transformer_integration_tests/component_integration_test.dart index 461682f16..88fcfae80 100644 --- a/test/over_react/component_declaration/transformer_integration_tests/component_integration_test.dart +++ b/test/over_react/component_declaration/transformer_integration_tests/component_integration_test.dart @@ -22,12 +22,6 @@ import '../../../test_util/test_util.dart'; main() { group('transformed component integration:', () { - test('props class cannot be instantiated directly', () { - expect(() { - new ComponentTestProps(); - }, throwsA(const isInstanceOf())); - }); - test('component class can be instantiated directly', () { var instance; expect(() { diff --git a/test/over_react/shared/map_proxy_tests.dart b/test/over_react/shared/map_proxy_tests.dart index 897a53a97..12f2859a2 100644 --- a/test/over_react/shared/map_proxy_tests.dart +++ b/test/over_react/shared/map_proxy_tests.dart @@ -126,7 +126,10 @@ void mapProxyTests(Map mapProxyFactory(Map proxiedMap)) { expect(proxy.values, equals(['value'])); verify(mock.values); }); - }); + }, + // Mirrors don't work in the DDC. + tags: 'no-ddc' + ); } class MockMap extends Mock implements Map {} diff --git a/test/over_react/util/event_helpers_test.dart b/test/over_react/util/event_helpers_test.dart index a8f97f7e7..04a38d73b 100644 --- a/test/over_react/util/event_helpers_test.dart +++ b/test/over_react/util/event_helpers_test.dart @@ -73,7 +73,10 @@ main() { expect(syntheticKeyboardEvent.metaKey, isFalse); expect(syntheticKeyboardEvent.repeat, isFalse); expect(syntheticKeyboardEvent.shiftKey, isFalse); - }); + }, + // Mirrors don't work in the DDC. + tags: 'no-ddc' + ); test('wrapNativeMouseEvent', () { var nativeMouseEvent = new MockMouseEvent(); @@ -126,7 +129,10 @@ main() { expect(syntheticMouseEvent.screenX, isNull); expect(syntheticMouseEvent.screenY, isNull); expect(syntheticMouseEvent.shiftKey, isFalse); - }); + }, + // Mirrors don't work in the DDC. + tags: 'no-ddc' + ); test('fakeSyntheticFormEvent', () { var element = new DivElement(); diff --git a/test/over_react/util/handler_chain_util_test.dart b/test/over_react/util/handler_chain_util_test.dart index 6d445a809..7726f2c25 100644 --- a/test/over_react/util/handler_chain_util_test.dart +++ b/test/over_react/util/handler_chain_util_test.dart @@ -45,7 +45,7 @@ main() { /// Shared tests for [CallbackUtil] subclasses supporting different arities. /// /// Expects callback arguments to be typed to [TestGenericType]. - void sharedTests(CallbackUtil callbackUtil, int arity) { + void sharedTests(CallbackUtil callbackUtil, int arity) { List generateArgs() { return new List.generate(arity, (_) => new TestGenericType()); } @@ -158,7 +158,7 @@ main() { test('calls all functions in order', () { var calls = []; - List functions = new List.generate(5, (index) { + List functions = new List.generate(5, (index) { return createTestChainFunction(onCall: (args) { calls.add(['function_$index', args]); }); @@ -180,7 +180,7 @@ main() { }); test('returns false when any function returns false', () { - List functions = new List.generate(5, (_) => createTestChainFunction()); + List functions = new List.generate(5, (_) => createTestChainFunction()); functions.insert(2, createTestChainFunction(returnValue: false)); var chained = callbackUtil.chainFromList(functions); @@ -189,7 +189,7 @@ main() { }); test('returns null when no function returns false', () { - List functions = new List.generate(5, (_) => createTestChainFunction()); + List functions = new List.generate(5, (_) => createTestChainFunction()); var chained = callbackUtil.chainFromList(functions); @@ -201,7 +201,7 @@ main() { test('null functions', () { var calls = []; - List functions = new List.generate(5, (index) { + List functions = new List.generate(5, (index) { return createTestChainFunction(onCall: (args) { calls.add(['function_$index', args]); }); @@ -227,7 +227,7 @@ main() { }); test('an empty list of functions', () { - var chained = callbackUtil.chainFromList([]); + var chained = callbackUtil.chainFromList([]); expect(chained, const isInstanceOf()); expect(() => Function.apply(chained, generateArgs()), returnsNormally); @@ -236,7 +236,7 @@ main() { if (arity != 0) { test('has arguments typed to the specified generic parameters', () { - List functions = new List.generate(5, (_) => createTestChainFunction()); + List functions = new List.generate(5, (_) => createTestChainFunction()); functions.forEach((function) { expect(() => Function.apply(function, generateArgs()), returnsNormally, @@ -264,19 +264,19 @@ main() { } group('CallbackUtil0Arg', () { - sharedTests(const CallbackUtil0Arg(), 0); + sharedTests(const CallbackUtil0Arg(), 0); }); group('CallbackUtil1Arg', () { - sharedTests(const CallbackUtil1Arg(), 1); + sharedTests(const CallbackUtil1Arg(), 1); }); group('CallbackUtil2Arg', () { - sharedTests(const CallbackUtil2Arg(), 2); + sharedTests(const CallbackUtil2Arg(), 2); }); group('CallbackUtil3Arg', () { - sharedTests(const CallbackUtil3Arg(), 3); + sharedTests(const CallbackUtil3Arg(), 3); }); }); }); diff --git a/test/wsd_test_util/common_component_tests.dart b/test/wsd_test_util/common_component_tests.dart index df276caf5..92fe5d46f 100644 --- a/test/wsd_test_util/common_component_tests.dart +++ b/test/wsd_test_util/common_component_tests.dart @@ -38,9 +38,18 @@ Set getComponentPropKeys(BuilderOnlyUiFactory factory) { var definition = factory(); InstanceMirror definitionMirror = reflect(definition); + Map members; + + // instanceMembers is not implemented for the DDC and will throw is this test is loaded even if it's not run. + try { + members = definitionMirror.type.instanceMembers; + } catch(e) { + members = {}; + } + // Use prop getters on the props class to infer the prop keys for the component. // Set all props to null to create key-value pairs for each prop, and then return those keys. - definitionMirror.type.instanceMembers.values.forEach((MethodMirror decl) { + members.values.forEach((MethodMirror decl) { // Filter out all members except concrete instance getters. if (!decl.isGetter || decl.isSynthetic || decl.isStatic) { return;