Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(864)

Unified Diff: test/codegen/expect/lib/html/element_offset_test.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/codegen/expect/lib/html/element_offset_test.js
diff --git a/test/codegen/expect/lib/html/element_offset_test.js b/test/codegen/expect/lib/html/element_offset_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..def93ee88d25ad8c9cb1981bcde91dd40bce1231
--- /dev/null
+++ b/test/codegen/expect/lib/html/element_offset_test.js
@@ -0,0 +1,145 @@
+dart_library.library('lib/html/element_offset_test', null, /* Imports */[
+ 'dart_sdk',
+ 'unittest'
+], function load__element_offset_test(exports, dart_sdk, unittest) {
+ 'use strict';
+ const core = dart_sdk.core;
+ const html = dart_sdk.html;
+ const _interceptors = dart_sdk._interceptors;
+ const dart = dart_sdk.dart;
+ const dartx = dart_sdk.dartx;
+ const html_individual_config = unittest.html_individual_config;
+ const unittest$ = unittest.unittest;
+ const src__matcher__expect = unittest.src__matcher__expect;
+ const src__matcher__numeric_matchers = unittest.src__matcher__numeric_matchers;
+ const element_offset_test = Object.create(null);
+ let JSArrayOfElement = () => (JSArrayOfElement = dart.constFn(_interceptors.JSArray$(html.Element)))();
+ let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [])))();
+ let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [])))();
+ element_offset_test.main = function() {
+ html_individual_config.useHtmlIndividualConfiguration();
+ function initPage() {
+ let level1 = html.UListElement.new();
+ level1[dartx.classes].add('level-1');
+ level1[dartx.children][dartx.add]((() => {
+ let _ = html.LIElement.new();
+ _[dartx.innerHtml] = 'I';
+ return _;
+ })());
+ let itemii = html.LIElement.new();
+ itemii[dartx.classes].add('item-ii');
+ itemii[dartx.style][dartx.position] = 'relative';
+ itemii[dartx.style][dartx.top] = '4px';
+ itemii[dartx.innerHtml] = 'II';
+ level1[dartx.children][dartx.add](itemii);
+ let level2 = html.UListElement.new();
+ itemii[dartx.children][dartx.add](level2);
+ let itema = html.LIElement.new();
+ itema[dartx.classes].add('item-a');
+ itema[dartx.innerHtml] = 'A';
+ let item1 = html.LIElement.new();
+ item1[dartx.classes].add('item-1');
+ item1[dartx.innerHtml] = '1';
+ let item2 = html.LIElement.new();
+ item2[dartx.classes].add('item-2');
+ item2[dartx.innerHtml] = '2';
+ let level3 = html.UListElement.new();
+ level3[dartx.children][dartx.addAll](JSArrayOfElement().of([item1, item2]));
+ let itemb = html.LIElement.new();
+ itemb[dartx.classes].add('item-b');
+ itemb[dartx.style][dartx.position] = 'relative';
+ itemb[dartx.style][dartx.top] = '20px';
+ itemb[dartx.style][dartx.left] = '150px';
+ itemb[dartx.innerHtml] = 'B';
+ itemb[dartx.children][dartx.add](level3);
+ level2[dartx.children][dartx.addAll](JSArrayOfElement().of([itema, itemb, (() => {
+ let _ = html.LIElement.new();
+ _[dartx.innerHtml] = 'C';
+ return _;
+ })()]));
+ html.document[dartx.body][dartx.append](level1);
+ html.document[dartx.body][dartx.style][dartx.whiteSpace] = 'nowrap';
+ let bar = html.DivElement.new();
+ bar[dartx.classes].add('bar');
+ let style = bar[dartx.style];
+ style[dartx.position] = 'absolute';
+ style[dartx.top] = '8px';
+ style[dartx.left] = '90px';
+ let baz = html.DivElement.new();
+ baz[dartx.classes].add('baz');
+ style = baz[dartx.style];
+ style[dartx.position] = 'absolute';
+ style[dartx.top] = '600px';
+ style[dartx.left] = '7000px';
+ bar[dartx.children][dartx.add](baz);
+ let quux = html.DivElement.new();
+ quux[dartx.classes].add('quux');
+ let qux = html.DivElement.new();
+ qux[dartx.classes].add('qux');
+ qux[dartx.children][dartx.add](quux);
+ html.document[dartx.body][dartx.append](bar);
+ html.document[dartx.body][dartx.append](qux);
+ }
+ dart.fn(initPage, VoidTovoid());
+ unittest$.group('offset', dart.fn(() => {
+ unittest$.setUp(initPage);
+ unittest$.test('offsetTo', dart.fn(() => {
+ let itema = html.query('.item-a');
+ let itemb = html.query('.item-b');
+ let item1 = html.query('.item-1');
+ let itemii = html.query('.item-ii');
+ let level1 = html.query('.level-1');
+ let baz = html.query('.baz');
+ let bar = html.query('.bar');
+ let qux = html.query('.qux');
+ let quux = html.query('.quux');
+ let point = itema[dartx.offsetTo](itemii);
+ src__matcher__expect.expect(point.x, 40);
+ src__matcher__expect.expect(point.y, src__matcher__numeric_matchers.inInclusiveRange(16, 20));
+ src__matcher__expect.expect(baz[dartx.offsetTo](bar).x, 7000);
+ src__matcher__expect.expect(baz[dartx.offsetTo](bar).y, src__matcher__numeric_matchers.inInclusiveRange(599, 604));
+ qux[dartx.style][dartx.position] = 'fixed';
+ src__matcher__expect.expect(quux[dartx.offsetTo](qux).x, 0);
+ src__matcher__expect.expect(quux[dartx.offsetTo](qux).y, 0);
+ point = item1[dartx.offsetTo](itemb);
+ src__matcher__expect.expect(point.x, 40);
+ src__matcher__expect.expect(point.y, src__matcher__numeric_matchers.inInclusiveRange(16, 20));
+ point = itemb[dartx.offsetTo](itemii);
+ src__matcher__expect.expect(point.x, 190);
+ src__matcher__expect.expect(point.y, src__matcher__numeric_matchers.inInclusiveRange(52, 60));
+ point = item1[dartx.offsetTo](itemii);
+ src__matcher__expect.expect(point.x, 230);
+ src__matcher__expect.expect(point.y, src__matcher__numeric_matchers.inInclusiveRange(68, 80));
+ }, VoidTodynamic()));
+ unittest$.test('documentOffset', dart.fn(() => {
+ let bar = html.query('.bar');
+ let baz = html.query('.baz');
+ let qux = html.query('.qux');
+ let quux = html.query('.quux');
+ let itema = html.query('.item-a');
+ let itemb = html.query('.item-b');
+ let item1 = html.query('.item-1');
+ let itemii = html.query('.item-ii');
+ src__matcher__expect.expect(itema[dartx.documentOffset].x, 88);
+ src__matcher__expect.expect(itema[dartx.documentOffset].y, src__matcher__numeric_matchers.inInclusiveRange(111, 160));
+ src__matcher__expect.expect(itemii[dartx.documentOffset].x, 48);
+ src__matcher__expect.expect(itemii[dartx.documentOffset].y, src__matcher__numeric_matchers.inInclusiveRange(95, 145));
+ src__matcher__expect.expect(itemb[dartx.documentOffset].x, 238);
+ src__matcher__expect.expect(itemb[dartx.documentOffset].y, src__matcher__numeric_matchers.inInclusiveRange(147, 205));
+ src__matcher__expect.expect(item1[dartx.documentOffset].x, 278);
+ src__matcher__expect.expect(item1[dartx.documentOffset].y, src__matcher__numeric_matchers.inInclusiveRange(163, 222));
+ src__matcher__expect.expect(bar[dartx.documentOffset].x, 90);
+ src__matcher__expect.expect(bar[dartx.documentOffset].y, 8);
+ src__matcher__expect.expect(baz[dartx.documentOffset].x, 7090);
+ src__matcher__expect.expect(baz[dartx.documentOffset].y, 608);
+ src__matcher__expect.expect(qux[dartx.documentOffset].x, 8);
+ src__matcher__expect.expect(qux[dartx.documentOffset].y, src__matcher__numeric_matchers.inInclusiveRange(203, 240));
+ src__matcher__expect.expect(quux[dartx.documentOffset].x, 8);
+ src__matcher__expect.expect(quux[dartx.documentOffset].y, src__matcher__numeric_matchers.inInclusiveRange(203, 240));
+ }, VoidTodynamic()));
+ }, VoidTovoid()));
+ };
+ dart.fn(element_offset_test.main, VoidTodynamic());
+ // Exports:
+ exports.element_offset_test = element_offset_test;
+});
« no previous file with comments | « test/codegen/expect/lib/html/element_dimensions_test.js ('k') | test/codegen/expect/lib/html/element_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698