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.
9 <script src=
"../base.js"></script>
11 base
.require('base.unittest');
12 base
.require('ui.list_and_associated_view');
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;
37 function testListViewNamingWithField() {
38 var lav
= new ListAndAssociatedView();
44 var view
= new SimpleView();
47 lav
.listProperty
= 'x';
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();
73 var view
= new SimpleView();
76 lav
.listProperty
= 'title';
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();
92 var view
= new SimpleView();
95 lav
.listProperty
= 'x';
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
);