<commit_before>// Copyright (c) 2013 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.

base.require('cc.picture');
base.require('tracing.importer.trace_event_importer');
base.require('tracing.trace_model');
base.require('cc.picture_view_test_data');

'use strict';

base.unittest.testSuite('cc.picture', function() {
  test('basic', function() {
    var m = new tracing.TraceModel([g_picture_trace]);
    var p = base.dictionaryValues(m.processes)[0];
    var instance = p.objects.getAllInstancesNamed('cc::Picture')[0];
    var snapshot = instance.snapshots[0];

    assertTrue(snapshot instanceof cc.PictureSnapshot);
    instance.wasDeleted(150);
  });

  test('getOps', function() {
    var picture = new cc.PictureSnapshot({id: '31415'}, 10, {
      'params': {
        'opaque_rect': [-15, -15, 0, 0],
        'layer_rect': [-15, -15, 46, 833]
      },
      'skp64': 'DAAAAHYEAADzAQAABwAAAAFkYWVy8AAAAAgAAB4DAAAADAAAIAAAgD8AAIA/CAAAHgMAAAAcAAADAAAAAAAAAAAAwI5EAID5QwEAAADoAAAACAAAHgMAAAAMAAAjAAAAAAAAAAAMAAAjAAAAAAAAAAAcAAADAAAAAAAAAAAAwI5EAID5QwEAAADkAAAAGAAAFQEAAAAAAAAAAAAAAADAjkQAgPlDGAAAFQIAAAAAAAAAAAAAAADAjkQAgPlDCAAAHgMAAAAcAAADAAAAAAAAAAAAwI5EAID5QwEAAADgAAAAGAAAFQMAAAAAAKBAAACgQAAAgEIAAIBCBAAAHAQAABwEAAAcBAAAHHRjYWYBAAAADVNrU3JjWGZlcm1vZGVjZnB0AAAAAHlhcmGgAAAAIHRucAMAAAAAAEBBAACAPwAAAAAAAIA/AAAAAAAAgEAAAP//ADABAAAAAAAAAEBBAACAPwAAAAAAAIA/AAAAAAAAgED/////AjABAAAAAAAAAAAAAAAAAAEAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEEAAIA/AAAAAAAAgD8AAAAAAACAQP8AAP8AMAEAAAAAACBmb2U=' // @suppress longLineCheck
    });
    picture.preInitialize();
    picture.initialize();

    var ops = picture.getOps();
    assertEquals(22, ops.length);

    var op0 = ops[0];
    assertEquals('Save', op0.cmd_string);
    assertTrue(op0.info instanceof Array);
  });
});
<commit_msg>Add null check for when getOps is disabled<commit_after>// Copyright (c) 2013 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.

base.require('cc.picture');
base.require('tracing.importer.trace_event_importer');
base.require('tracing.trace_model');
base.require('cc.picture_view_test_data');

'use strict';

base.unittest.testSuite('cc.picture', function() {
  test('basic', function() {
    var m = new tracing.TraceModel([g_picture_trace]);
    var p = base.dictionaryValues(m.processes)[0];
    var instance = p.objects.getAllInstancesNamed('cc::Picture')[0];
    var snapshot = instance.snapshots[0];

    assertTrue(snapshot instanceof cc.PictureSnapshot);
    instance.wasDeleted(150);
  });

  test('getOps', function() {
    var picture = new cc.PictureSnapshot({id: '31415'}, 10, {
      'params': {
        'opaque_rect': [-15, -15, 0, 0],
        'layer_rect': [-15, -15, 46, 833]
      },
      'skp64': 'DAAAAHYEAADzAQAABwAAAAFkYWVy8AAAAAgAAB4DAAAADAAAIAAAgD8AAIA/CAAAHgMAAAAcAAADAAAAAAAAAAAAwI5EAID5QwEAAADoAAAACAAAHgMAAAAMAAAjAAAAAAAAAAAMAAAjAAAAAAAAAAAcAAADAAAAAAAAAAAAwI5EAID5QwEAAADkAAAAGAAAFQEAAAAAAAAAAAAAAADAjkQAgPlDGAAAFQIAAAAAAAAAAAAAA<KEY>DC<KEY>EEAAIA/AAAAAAAA<KEY>ACAQP8AAP<KEY> // @suppress longLineCheck
    });
    picture.preInitialize();
    picture.initialize();

    var ops = picture.getOps();
    if (!ops)
      return;
    assertEquals(22, ops.length);

    var op0 = ops[0];
    assertEquals('Save', op0.cmd_string);
    assertTrue(op0.info instanceof Array);
  });
});

{'fraction_non_alphanumeric': 0.12288742480664566, 'fraction_numerical': 0.02979089086221713, 'mean_word_length': 5.169611307420495, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 23, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4083575', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1233, 'n_words': 198}