Re-enable index-basics-workers test to see if still times
[chromium-blink-merge.git] / tools / cc-frame-viewer / src / ui / list_and_associated_view_test.html
blob866d2570ccd1e26d79fea852bda33a61df4ea97e
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 Copyright (c) 2012 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file.
7 -->
8 <head>
9 <script src="../base.js"></script>
10 <script>
11 base.require('base.unittest');
12 base.require('ui.list_and_associated_view');
13 </script>
14 </head>
15 <body>
16 <script>
17 'use strict';
19 var ListAndAssociatedView = ui.ListAndAssociatedView;
21 var SimpleView = ui.define('div');
22 SimpleView.prototype = {
23 __proto__: HTMLDivElement.prototype,
25 decorate: function() {
26 this.item_ = undefined;
29 set item(item) {
30 this.item_ = item;
32 get item() {
33 return this.item_;
37 function testListViewNamingWithField() {
38 var lav = new ListAndAssociatedView();
39 var list = [
40 {x: '1'},
41 {x: '2'},
42 {x: '3'}
44 var view = new SimpleView();
46 lav.list = list;
47 lav.listProperty = 'x';
48 lav.view = view;
49 lav.viewProperty = 'item';
51 var lavListView = lav.listView;
52 assertEquals(3, lavListView.children.length);
53 assertEquals('1', lavListView.children[0].textContent);
56 function testListViewNamingWithProperty() {
57 var lav = new ListAndAssociatedView();
59 function X(x) {
60 this.x = x;
62 X.prototype = {
63 get title() {
64 return this.x;
68 var list = [
69 new X('1'),
70 new X('2'),
71 new X('3')
73 var view = new SimpleView();
75 lav.list = list;
76 lav.listProperty = 'title';
77 lav.view = view;
78 lav.viewProperty = 'item';
80 var lavListView = lav.listView;
81 assertEquals(3, lavListView.children.length);
82 assertEquals('1', lavListView.children[0].textContent);
85 function testSelectionChangesView() {
86 var lav = new ListAndAssociatedView();
87 var list = [
88 {x: '1'},
89 {x: '2'},
90 {x: '3'}
92 var view = new SimpleView();
94 lav.list = list;
95 lav.listProperty = 'x';
96 lav.view = view;
97 lav.viewProperty = 'item';
98 var lavListView = lav.listView;
100 assertEquals(list[0], view.item);
101 lavListView.children[1].selected = true;
102 assertEquals(list[1], view.item);
104 </script>
105 </body>
106 </html>