1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 base.require('ui.list_and_associated_view');
9 base.unittest.testSuite('ui.list_and_associated_view', function() {
10 var ListAndAssociatedView = ui.ListAndAssociatedView;
12 var SimpleView = ui.define('div');
13 SimpleView.prototype = {
14 __proto__: HTMLDivElement.prototype,
16 decorate: function() {
17 this.item_ = undefined;
28 test('listViewNamingWithField', function() {
29 var lav = new ListAndAssociatedView();
35 var view = new SimpleView();
38 lav.listProperty = 'x';
40 lav.viewProperty = 'item';
42 var lavListView = lav.listView;
43 assertEquals(3, lavListView.children.length);
44 assertEquals('1', lavListView.children[0].textContent);
47 test('listViewNamingWithProperty', function() {
48 var lav = new ListAndAssociatedView();
64 var view = new SimpleView();
67 lav.listProperty = 'title';
69 lav.viewProperty = 'item';
71 var lavListView = lav.listView;
72 assertEquals(3, lavListView.children.length);
73 assertEquals('1', lavListView.children[0].textContent);
76 test('selectionChangesView', function() {
77 var lav = new ListAndAssociatedView();
83 var view = new SimpleView();
86 lav.listProperty = 'x';
88 lav.viewProperty = 'item';
89 var lavListView = lav.listView;
91 assertEquals(list[0], view.item);
92 lavListView.children[1].selected = true;
93 assertEquals(list[1], view.item);