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

Side by Side Diff: tracing/tracing/value/ui/value_set_view_test.html

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge 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 unified diff | Download patch
« no previous file with comments | « tracing/tracing/value/ui/value_set_view.html ('k') | tracing/tracing/value/unit.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!--
3 Copyright 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7
8 <link rel="import" href="/tracing/value/ui/value_set_table.html">
9 <link rel="import" href="/tracing/value/ui/value_set_view.html">
10 <link rel="import" href="/tracing/value/value_set.html">
11
12 <dom-module id='test-value-set-view'>
13 <template>
14 <style>
15 :host {
16 display: flex;
17 flex-direction: column;
18 }
19 </style>
20 <content></content>
21 </template>
22 </dom-module>
23
24 <script>
25 'use strict';
26
27 var useTestView = false;
28
29 tr.exportTo('tr.v.ui', function() {
30 Polymer({
31 is: 'test-value-set-view',
32
33 supportsValueSet: function(values) {
34 return useTestView;
35 },
36
37 get tabLabel() {
38 return 'Test';
39 },
40
41 ready: function() {
42 this.values_ = undefined;
43 },
44
45 get values() {
46 return this.values_;
47 },
48
49 /**
50 * @param {!tr.v.ValueSet} values
51 */
52 set values(values) {
53 this.values_ = values;
54 }
55 });
56
57 tr.v.ui.registerValueSetView('test-value-set-view');
58
59 return {};
60 });
61
62 tr.b.unittest.testSuite(function() {
63 var TEST_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear(
64 tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 1000),
65 20);
66
67 test('instantiate0', function() {
68 // Empty setting, single view
69 // Test that the single view is automatically selected,
70 // and that the tab-strip is hidden.
71 tr.b.Settings.set(tr.v.ui.SELECTED_TAB_SETTINGS_KEY, '');
72 useTestView = false;
73 var view = document.createElement('tr-v-ui-value-set-view');
74 var values = new tr.v.ValueSet();
75
76 var numeric = TEST_NUMERIC_BUILDER.build();
77 for (var i = 0; i < 1e2; ++i) {
78 numeric.add(Math.random() * TEST_NUMERIC_BUILDER.maxBinBoundary);
79 }
80 var foo = new tr.v.NumericValue('foo', numeric, {description: 'bar'});
81 values.addValue(foo);
82
83 this.addHTMLOutput(view);
84 view.values = values;
85
86 var tabView = tr.b.findDeepElementMatchingPredicate(
87 view, function(element) {
88 return element.tagName.toLowerCase() === 'tr-ui-a-tab-view';
89 });
90 assert.equal(tabView.selectedSubView, tabView.get('tabs.0'));
91 assert.isTrue(tabView.get('tabsHidden'));
92 });
93
94 test('instantiate1', function() {
95 // Empty setting, two views
96 // Test that the 0th view is automatically selected,
97 // and that the tab-strip is visible.
98 tr.b.Settings.set(tr.v.ui.SELECTED_TAB_SETTINGS_KEY, '');
99 useTestView = true;
100 var view = document.createElement('tr-v-ui-value-set-view');
101 var values = new tr.v.ValueSet();
102
103 var numeric = TEST_NUMERIC_BUILDER.build();
104 for (var i = 0; i < 1e2; ++i) {
105 numeric.add(Math.random() * TEST_NUMERIC_BUILDER.maxBinBoundary);
106 }
107 var foo = new tr.v.NumericValue('foo', numeric, {description: 'bar'});
108 values.addValue(foo);
109
110 this.addHTMLOutput(view);
111
112 view.values = values;
113 var tabView = tr.b.findDeepElementMatchingPredicate(
114 view, function(element) {
115 return element.tagName.toLowerCase() === 'tr-ui-a-tab-view';
116 });
117 assert.equal(tabView.selectedSubView, tabView.get('tabs.0'));
118 assert.isFalse(tabView.get('tabsHidden'));
119 });
120
121 test('instantiate2', function() {
122 // Set setting to the test view, two views
123 // Test that the test view is automatically selected,
124 // and that the tab-strip is visible.
125 tr.b.Settings.set(tr.v.ui.SELECTED_TAB_SETTINGS_KEY, 'test-value-set-view');
126 useTestView = true;
127 var view = document.createElement('tr-v-ui-value-set-view');
128 var values = new tr.v.ValueSet();
129
130 var numeric = TEST_NUMERIC_BUILDER.build();
131 for (var i = 0; i < 1e2; ++i) {
132 numeric.add(Math.random() * TEST_NUMERIC_BUILDER.maxBinBoundary);
133 }
134 var foo = new tr.v.NumericValue('foo', numeric, {description: 'bar'});
135 values.addValue(foo);
136
137 view.values = values;
138 this.addHTMLOutput(view);
139
140 var tabView = tr.b.findDeepElementMatchingPredicate(
141 view, function(element) {
142 return element.tagName.toLowerCase() === 'tr-ui-a-tab-view';
143 });
144 assert.equal(tabView.selectedSubView, tabView.get('tabs.1'));
145 assert.isFalse(tabView.get('tabsHidden'));
146
147 // Test that selecting the Table view changes the setting.
148 tabView.selectedTab = tabView.tabs[0];
149 return new Promise(function(resolve, reject) {
150 assert.strictEqual(
151 tr.b.Settings.get(tr.v.ui.SELECTED_TAB_SETTINGS_KEY),
152 'tr-v-ui-value-set-table');
153 resolve();
154 });
155 });
156
157 test('instantiate3', function() {
158 // Set setting to the test view, but disable it
159 // Test that the 0th view is automatically selected,
160 // and that the tab-strip is hidden.
161 tr.b.Settings.set(tr.v.ui.SELECTED_TAB_SETTINGS_KEY, 'test-value-set-view');
162 useTestView = false;
163 var view = document.createElement('tr-v-ui-value-set-view');
164 var values = new tr.v.ValueSet();
165
166 var numeric = TEST_NUMERIC_BUILDER.build();
167 for (var i = 0; i < 1e2; ++i) {
168 numeric.add(Math.random() * TEST_NUMERIC_BUILDER.maxBinBoundary);
169 }
170 var foo = new tr.v.NumericValue('foo', numeric, {description: 'bar'});
171 values.addValue(foo);
172
173 view.values = values;
174 this.addHTMLOutput(view);
175
176 var tabView = tr.b.findDeepElementMatchingPredicate(
177 view, function(element) {
178 return element.tagName.toLowerCase() === 'tr-ui-a-tab-view';
179 });
180 assert.equal(tabView.selectedSubView, tabView.get('tabs.0'));
181 assert.isTrue(tabView.get('tabsHidden'));
182 });
183 });
184 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/value/ui/value_set_view.html ('k') | tracing/tracing/value/unit.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698