<commit_before><html>
<head>
<script src="../../lib/OpenLayers.js"></script>
  <script type="text/javascript">

    var name = "Vector Layer";
    
    function test_Layer_Vector_constructor(t) {
        t.plan(4);

        var options = {protocol: new OpenLayers.Protocol(), 
                       strategies: [new OpenLayers.Strategy(), new OpenLayers.Strategy()]}
        var layer = new OpenLayers.Layer.Vector(name, options);

        t.ok(layer instanceof OpenLayers.Layer.Vector, "new OpenLayers.Layer.Vector returns correct object" );
        t.eq(layer.name, name, "layer name is correctly set");
        t.ok(layer.renderer.CLASS_NAME, "layer has a renderer");
        
        t.ok((layer.name == layer.strategies[0].layer.name) &&
             (layer.strategies[0].layer.name == layer.strategies[1].layer.name), 
             "setLayer was called on strategies");
    }

    function test_Layer_Vector_refresh(t) {
        t.plan(1);

        var obj = {"an": "object"};

        var layer = new OpenLayers.Layer.Vector(name, {
            eventListeners: {
                refresh: function(o) {
                    t.ok(o == obj,
                         "refresh listener called with correct arg");
                }
            }
        });

        // 0 test
        layer.inRange = false;
        layer.visibility = false;
        layer.refresh(obj);

        // 0 test
        layer.inRange = true;
        layer.visibility = false;
        layer.refresh(obj);

        // 0 test
        layer.inRange = false;
        layer.visibility = true;
        layer.refresh(obj);
      
        // 1 test
        layer.inRange = true;
        layer.visibility = true;
        layer.refresh(obj);
    }
    
    function test_Layer_Vector_addFeatures(t) {
        t.plan(8);
    
        var layer = new OpenLayers.Layer.Vector(name);

        var point = new OpenLayers.Geometry.Point(-111.04, 45.68);
        var pointFeature = new OpenLayers.Feature.Vector(point);

        layer.preFeatureInsert = function(feature) {
            t.ok(feature == pointFeature, "OpenLayers.Layer.Vector.addFeatures calls preFeatureInsert with the right arg");
        };
        layer.onFeatureInsert = function(feature) {
            t.ok(feature == pointFeature, "OpenLayers.Layer.Vector.addFeatures calls onFeatureInsert with the right arg");
        };
        layer.events.register('beforefeatureadded', null, function(obj) {
            t.ok(pointFeature == obj.feature, "OpenLayers.Layer.Vector.addFeatures triggers beforefeatureadded with correct feature passed to callback");
        });
        layer.events.register('featureadded', null, function(obj) {
            t.ok(pointFeature == obj.feature, "OpenLayers.Layer.Vector.addFeatures triggers featureadded with correct feature passed to callback");
        });
        layer.events.register('featuresadded', null, function(obj) {
            t.ok(pointFeature == obj.features[0], "OpenLayers.Layer.Vector.addFeatures triggers featuresadded with correct features passed to callback");
        });

        layer.addFeatures([pointFeature]);<commit_msg>Vector tests broke with r9164.  Fixing tests by mocking up calculateInRange instead of just inRange.  (closes #1939)<commit_after><html>
<head>
<script src="../../lib/OpenLayers.js"></script>
  <script type="text/javascript">

    var name = "Vector Layer";
    
    function test_Layer_Vector_constructor(t) {
        t.plan(4);

        var options = {protocol: new OpenLayers.Protocol(), 
                       strategies: [new OpenLayers.Strategy(), new OpenLayers.Strategy()]}
        var layer = new OpenLayers.Layer.Vector(name, options);

        t.ok(layer instanceof OpenLayers.Layer.Vector, "new OpenLayers.Layer.Vector returns correct object" );
        t.eq(layer.name, name, "layer name is correctly set");
        t.ok(layer.renderer.CLASS_NAME, "layer has a renderer");
        
        t.ok((layer.name == layer.strategies[0].layer.name) &&
             (layer.strategies[0].layer.name == layer.strategies[1].layer.name), 
             "setLayer was called on strategies");
    }

    function test_Layer_Vector_refresh(t) {
        t.plan(4);

        var obj = {"an": "object"};

        var log;
        var layer = new OpenLayers.Layer.Vector(name, {
            eventListeners: {
                refresh: function(o) {
                    log.obj = o;
                }
            }
        });
        inRange = false;
        layer.calculateInRange = function() {
            return inRange;
        };

        log = {};
        inRange = false;
        layer.visibility = false;
        layer.refresh(obj);
        t.eq(log.obj, undefined, "[false, false] refresh not triggered");

        log = {};
        inRange = true;
        layer.visibility = false;
        layer.refresh(obj);
        t.eq(log.obj, undefined, "[true, false] refresh not triggered");

        log = {};
        inRange = false;
        layer.visibility = true;
        layer.refresh(obj);
        t.eq(log.obj, undefined, "[false, true] refresh not triggered");

        log = {};
        inRange = true;
        layer.visibility = true;
        layer.refresh(obj);
        t.ok(log.obj === obj, "[true, true] refresh triggered with correct arg");
    }
    
    function test_Layer_Vector_addFeatures(t) {
        t.plan(8);
    
        var layer = new OpenLayers.Layer.Vector(name);

        var point = new OpenLayers.Geometry.Point(-111.04, 45.68);
        var pointFeature = new OpenLayers.Feature.Vector(point);

        layer.preFeatureInsert = function(feature) {
            t.ok(feature == pointFeature, "OpenLayers.Layer.Vector.addFeatures calls preFeatureInsert with the right arg");
        };
        layer.onFeatureInsert = function(feature) {
            t.ok(feature == pointFeature, "OpenLayers.Layer.Vector.addFeatures calls onFeatureInsert with the right arg");
        };
        layer.events.register('beforefeatureadded', null, function(obj) {
            t.ok(pointFeature == obj.feature, "OpenLayers.Layer.Vector.addFeatures triggers beforefeatureadded with correct feature passed to callback");
        });
        layer.events.register('featureadded', null, function(obj) {
            t.ok(pointFeature == obj.feature, "OpenLayers.Layer.Vector.addFeatures triggers featureadded with correct feature passed to callback");
        });
        layer.events.register('featuresadded', null, function(obj) {
            t.ok(pointFeature == obj.features[0], "OpenLayers.Layer.Vector.addFeatures triggers featuresadded with correct features passed to callback");
        });

        layer.addFeatures([pointFeature]);
{'fraction_non_alphanumeric': 0.12139423076923077, 'fraction_numerical': 0.006610576923076923, 'mean_word_length': 2.2955445544554456, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 13, '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': '2452072', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1802, 'n_words': 419}