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

Side by Side Diff: test/codegen/lib/html/selectelement_test.dart

Issue 1930043002: Add all dart:html tests from the sdk to test/codegen. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: ptal Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library selectelement_test;
6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart';
8 import 'dart:html';
9
10 main() {
11 useHtmlConfiguration();
12
13 test('selectedOptions', () {
14 var element = new SelectElement();
15 element.multiple = false;
16 var options = [
17 new OptionElement(),
18 new DivElement(),
19 new OptionElement(data: 'data', value: 'two', selected: true),
20 new DivElement(),
21 new OptionElement(data: 'data', value: 'two', selected: true),
22 new OptionElement(),
23 ];
24 element.children.addAll(options);
25 expect(element.selectedOptions.length, 1);
26 expect(element.selectedOptions[0], equals(options[4]));
27 });
28
29 test('multiple selectedOptions', () {
30 var element = new SelectElement();
31 element.multiple = true;
32 var options = [
33 new OptionElement(),
34 new DivElement(),
35 new OptionElement(data: 'data', value: 'two', selected: true),
36 new DivElement(),
37 new OptionElement(data: 'data', value: 'two', selected: true),
38 new OptionElement(),
39 new OptionElement(data: 'data', value: 'two', selected: false),
40 ];
41 element.children.addAll(options);
42 expect(element.selectedOptions.length, 2);
43 expect(element.selectedOptions[0], equals(options[2]));
44 expect(element.selectedOptions[1], equals(options[4]));
45 });
46
47 test('options', () {
48 var element = new SelectElement();
49 var options = [
50 new OptionElement(),
51 new OptionElement(data: 'data', value: 'two', selected: true),
52 new OptionElement(data: 'data', value: 'two', selected: true),
53 new OptionElement(),
54 ];
55 element.children.addAll(options);
56 // Use last to make sure that the list was correctly wrapped.
57 expect(element.options.last, equals(options[3]));
58 });
59
60 test('optgroup', () {
61 var element = new Element.html(
62 '<select>'
63 '<option>1</option>'
64 '<optgroup>'
65 '<option>2</option>'
66 '</optgroup>'
67 '</select>');
68
69 expect(element.options.length, 2);
70 element.selectedIndex = 1;
71
72 var optGroup = element.children[1];
73 expect(optGroup is OptGroupElement, isTrue);
74 expect(optGroup.children.single.selected, isTrue);
75 expect(element.selectedOptions, optGroup.children);
76 });
77 }
OLDNEW
« no previous file with comments | « test/codegen/lib/html/scripts_test_js.js ('k') | test/codegen/lib/html/serialized_script_value_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698