<commit_before>// ==========================================================================
// Project:  SproutCore Runtime
// Copyright: ©2011 Strobe Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

var set = SC.set;
var get = SC.get;

var application;
var manager;
var numStart, numMove, numEnd, numCancel;

var gesture = SC.Object.extend({
  touchStart: function(evt, view, manager) {
    numStart++;            
    if (view) manager.redispatchEventToView(view, 'touchstart')
  },
  touchMove: function(evt, view, manager) {
    numMove++;            
    if (view) manager.redispatchEventToView(view, 'touchmove')
  },
  touchEnd: function(evt, view, manager) {
    numEnd++;            
    if (view) manager.redispatchEventToView(view, 'touchend')
  },
  touchCancel: function(evt, view, manager) {
    numCancel++;            
    if (view) manager.redispatchEventToView(view, 'touchcancel')
  }
});

module("Gesture Manager",{
  setup: function() {
    numStart = numMove = numEnd = numCancel = 0;

    application = SC.Application.create();

    manager = SC.GestureManager.create({
      gestures: [
        gesture.create(),
        gesture.create()
      ]
    });
  },

  teardown: function() {
    manager.destroy();
    application.destroy();
  }
});

test("manager should re-dispatch events to all gestures", function() {
  manager.touchStart();
  equals(numStart,2,"dispatch start event to all gestures");

  manager.touchMove();
  equals(numMove,2,"dispatch move event to all gestures");

  manager.touchEnd();
  equals(numEnd,2,"dispatch end event to all gestures");

  manager.touchCancel();
  equals(numCancel,2,"dispatch cancel event to all gestures");
});

test("manager should re-dispatch event to view", function() {
  var numViewStart =  numViewMove = numViewEnd = numViewCancel = 0;

  var view = SC.View.create({
    eventManager: manager,<commit_msg>Fix bug introduced by new asserts.<commit_after>// ==========================================================================
// Project:  SproutCore Runtime
// Copyright: ©2011 Strobe Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

var set = SC.set;
var get = SC.get;

var application;
var manager;
var numStart, numMove, numEnd, numCancel;

var view = SC.View.create();
var manager = SC.GestureManager.create()

var gesture = SC.Object.extend({
  touchStart: function(evt, view, manager) {
    numStart++;            
    if (view) manager.redispatchEventToView(view, 'touchstart')
  },
  touchMove: function(evt, view, manager) {
    numMove++;            
    if (view) manager.redispatchEventToView(view, 'touchmove')
  },
  touchEnd: function(evt, view, manager) {
    numEnd++;            
    if (view) manager.redispatchEventToView(view, 'touchend')
  },
  touchCancel: function(evt, view, manager) {
    numCancel++;            
    if (view) manager.redispatchEventToView(view, 'touchcancel')
  }
});

module("Gesture Manager",{
  setup: function() {
    numStart = numMove = numEnd = numCancel = 0;

    application = SC.Application.create();

    manager = SC.GestureManager.create({
      gestures: [
        gesture.create(),
        gesture.create()
      ]
    });
  },

  teardown: function() {
    manager.destroy();
    application.destroy();
  }
});

test("manager should re-dispatch events to all gestures", function() {
  var evt = {};
  manager.touchStart(evt, view);
  equals(numStart,2,"dispatch start event to all gestures");

  manager.touchMove(evt, view);
  equals(numMove,2,"dispatch move event to all gestures");

  manager.touchEnd(evt, view);
  equals(numEnd,2,"dispatch end event to all gestures");

  manager.touchCancel(evt, view);
  equals(numCancel,2,"dispatch cancel event to all gestures");
});

test("manager should re-dispatch event to view", function() {
  var numViewStart =  numViewMove = numViewEnd = numViewCancel = 0;

  var view = SC.View.create({
    eventManager: manager,
{'fraction_non_alphanumeric': 0.19670542635658914, 'fraction_numerical': 0.0048449612403100775, 'mean_word_length': 3.7678983833718247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '2275096', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1183, 'n_words': 306}