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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/value/ui/value_set_view_test.html
diff --git a/tracing/tracing/value/ui/value_set_view_test.html b/tracing/tracing/value/ui/value_set_view_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..e5e4cc78f3315078596fa53ce375461efeedfee5
--- /dev/null
+++ b/tracing/tracing/value/ui/value_set_view_test.html
@@ -0,0 +1,184 @@
+<!DOCTYPE html>
+<!--
+Copyright 2016 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+
+<link rel="import" href="/tracing/value/ui/value_set_table.html">
+<link rel="import" href="/tracing/value/ui/value_set_view.html">
+<link rel="import" href="/tracing/value/value_set.html">
+
+<dom-module id='test-value-set-view'>
+ <template>
+ <style>
+ :host {
+ display: flex;
+ flex-direction: column;
+ }
+ </style>
+ <content></content>
+ </template>
+</dom-module>
+
+<script>
+'use strict';
+
+var useTestView = false;
+
+tr.exportTo('tr.v.ui', function() {
+ Polymer({
+ is: 'test-value-set-view',
+
+ supportsValueSet: function(values) {
+ return useTestView;
+ },
+
+ get tabLabel() {
+ return 'Test';
+ },
+
+ ready: function() {
+ this.values_ = undefined;
+ },
+
+ get values() {
+ return this.values_;
+ },
+
+ /**
+ * @param {!tr.v.ValueSet} values
+ */
+ set values(values) {
+ this.values_ = values;
+ }
+ });
+
+ tr.v.ui.registerValueSetView('test-value-set-view');
+
+ return {};
+});
+
+tr.b.unittest.testSuite(function() {
+ var TEST_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear(
+ tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 1000),
+ 20);
+
+ test('instantiate0', function() {
+ // Empty setting, single view
+ // Test that the single view is automatically selected,
+ // and that the tab-strip is hidden.
+ tr.b.Settings.set(tr.v.ui.SELECTED_TAB_SETTINGS_KEY, '');
+ useTestView = false;
+ var view = document.createElement('tr-v-ui-value-set-view');
+ var values = new tr.v.ValueSet();
+
+ var numeric = TEST_NUMERIC_BUILDER.build();
+ for (var i = 0; i < 1e2; ++i) {
+ numeric.add(Math.random() * TEST_NUMERIC_BUILDER.maxBinBoundary);
+ }
+ var foo = new tr.v.NumericValue('foo', numeric, {description: 'bar'});
+ values.addValue(foo);
+
+ this.addHTMLOutput(view);
+ view.values = values;
+
+ var tabView = tr.b.findDeepElementMatchingPredicate(
+ view, function(element) {
+ return element.tagName.toLowerCase() === 'tr-ui-a-tab-view';
+ });
+ assert.equal(tabView.selectedSubView, tabView.get('tabs.0'));
+ assert.isTrue(tabView.get('tabsHidden'));
+ });
+
+ test('instantiate1', function() {
+ // Empty setting, two views
+ // Test that the 0th view is automatically selected,
+ // and that the tab-strip is visible.
+ tr.b.Settings.set(tr.v.ui.SELECTED_TAB_SETTINGS_KEY, '');
+ useTestView = true;
+ var view = document.createElement('tr-v-ui-value-set-view');
+ var values = new tr.v.ValueSet();
+
+ var numeric = TEST_NUMERIC_BUILDER.build();
+ for (var i = 0; i < 1e2; ++i) {
+ numeric.add(Math.random() * TEST_NUMERIC_BUILDER.maxBinBoundary);
+ }
+ var foo = new tr.v.NumericValue('foo', numeric, {description: 'bar'});
+ values.addValue(foo);
+
+ this.addHTMLOutput(view);
+
+ view.values = values;
+ var tabView = tr.b.findDeepElementMatchingPredicate(
+ view, function(element) {
+ return element.tagName.toLowerCase() === 'tr-ui-a-tab-view';
+ });
+ assert.equal(tabView.selectedSubView, tabView.get('tabs.0'));
+ assert.isFalse(tabView.get('tabsHidden'));
+ });
+
+ test('instantiate2', function() {
+ // Set setting to the test view, two views
+ // Test that the test view is automatically selected,
+ // and that the tab-strip is visible.
+ tr.b.Settings.set(tr.v.ui.SELECTED_TAB_SETTINGS_KEY, 'test-value-set-view');
+ useTestView = true;
+ var view = document.createElement('tr-v-ui-value-set-view');
+ var values = new tr.v.ValueSet();
+
+ var numeric = TEST_NUMERIC_BUILDER.build();
+ for (var i = 0; i < 1e2; ++i) {
+ numeric.add(Math.random() * TEST_NUMERIC_BUILDER.maxBinBoundary);
+ }
+ var foo = new tr.v.NumericValue('foo', numeric, {description: 'bar'});
+ values.addValue(foo);
+
+ view.values = values;
+ this.addHTMLOutput(view);
+
+ var tabView = tr.b.findDeepElementMatchingPredicate(
+ view, function(element) {
+ return element.tagName.toLowerCase() === 'tr-ui-a-tab-view';
+ });
+ assert.equal(tabView.selectedSubView, tabView.get('tabs.1'));
+ assert.isFalse(tabView.get('tabsHidden'));
+
+ // Test that selecting the Table view changes the setting.
+ tabView.selectedTab = tabView.tabs[0];
+ return new Promise(function(resolve, reject) {
+ assert.strictEqual(
+ tr.b.Settings.get(tr.v.ui.SELECTED_TAB_SETTINGS_KEY),
+ 'tr-v-ui-value-set-table');
+ resolve();
+ });
+ });
+
+ test('instantiate3', function() {
+ // Set setting to the test view, but disable it
+ // Test that the 0th view is automatically selected,
+ // and that the tab-strip is hidden.
+ tr.b.Settings.set(tr.v.ui.SELECTED_TAB_SETTINGS_KEY, 'test-value-set-view');
+ useTestView = false;
+ var view = document.createElement('tr-v-ui-value-set-view');
+ var values = new tr.v.ValueSet();
+
+ var numeric = TEST_NUMERIC_BUILDER.build();
+ for (var i = 0; i < 1e2; ++i) {
+ numeric.add(Math.random() * TEST_NUMERIC_BUILDER.maxBinBoundary);
+ }
+ var foo = new tr.v.NumericValue('foo', numeric, {description: 'bar'});
+ values.addValue(foo);
+
+ view.values = values;
+ this.addHTMLOutput(view);
+
+ var tabView = tr.b.findDeepElementMatchingPredicate(
+ view, function(element) {
+ return element.tagName.toLowerCase() === 'tr-ui-a-tab-view';
+ });
+ assert.equal(tabView.selectedSubView, tabView.get('tabs.0'));
+ assert.isTrue(tabView.get('tabsHidden'));
+ });
+});
+</script>
« 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