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. 4 5'use strict'; 6 7base.require('cc.picture_ops_list_view'); 8base.require('cc.picture'); 9base.require('cc.layer_tree_host_impl_test_data'); 10base.require('tracing.importer.trace_event_importer'); 11base.require('tracing.trace_model'); 12 13base.unittest.testSuite('cc.picture_ops_list_view', function() { 14 var PictureOpsListView = cc.PictureOpsListView; 15 16 test('instantiate', function() { 17 if (!cc.PictureSnapshot.CanRasterize()) 18 return; 19 var m = new tracing.TraceModel(g_catLTHIEvents); 20 var p = base.dictionaryValues(m.processes)[0]; 21 22 var instance = p.objects.getAllInstancesNamed('cc::Picture')[0]; 23 var snapshot = instance.snapshots[0]; 24 25 var view = new PictureOpsListView(); 26 view.picture = snapshot; 27 assertEquals(627, view.opsList_.children.length); 28 }); 29 30 test('selection', function() { 31 if (!cc.PictureSnapshot.CanRasterize()) 32 return; 33 var m = new tracing.TraceModel(g_catLTHIEvents); 34 var p = base.dictionaryValues(m.processes)[0]; 35 36 var instance = p.objects.getAllInstancesNamed('cc::Picture')[0]; 37 var snapshot = instance.snapshots[0]; 38 39 var view = new PictureOpsListView(); 40 view.picture = snapshot; 41 var didSelectionChange = 0; 42 view.addEventListener('selection-changed', function() { 43 didSelectionChange = true; 44 }); 45 assertFalse(didSelectionChange); 46 view.opsList_.selectedElement = view.opsList_.children[3]; 47 assertTrue(didSelectionChange); 48 }); 49 50}); 51