From 798c91f684f2c7c7b333f8442f1091a70b7b5000 Mon Sep 17 00:00:00 2001 From: deyihu Date: Sun, 21 Jan 2024 18:36:35 +0800 Subject: [PATCH] test env config mount to globalconfig --- src/GlobalConfig.js | 2 ++ src/core/Eventable.js | 4 ++-- src/geometry/GeometryCollection.js | 4 ++-- src/map/Map.DomEvents.js | 4 ++-- src/map/handler/Map.GeometryEvents.js | 4 ++-- test/SpecCommon.js | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/GlobalConfig.js b/src/GlobalConfig.js index df7c989f0c..1b718f8455 100644 --- a/src/GlobalConfig.js +++ b/src/GlobalConfig.js @@ -3,6 +3,8 @@ * idle/worker etc */ const GlobalConfig = { + //test env + isTest: false, //idle logging idleLog: false, //idle 时间阈值 diff --git a/src/core/Eventable.js b/src/core/Eventable.js index eda8cd8f25..e54f6a5f0a 100644 --- a/src/core/Eventable.js +++ b/src/core/Eventable.js @@ -1,4 +1,4 @@ -import Browser from './Browser'; +import GlobalConfig from '../GlobalConfig'; import { extend, isString, isNil, UID, isNumber } from './util'; import { stopPropagation } from './util/dom'; /** @@ -69,7 +69,7 @@ const Eventable = Base => if (l > 0) { for (let i = 0; i < l; i++) { if (handler === handlerChain[i].handler && handlerChain[i].context === context) { - if (!Browser.isTest) { + if (!GlobalConfig.isTest) { console.warn(this, `find '${eventsOn}' handler:`, handler, ' The old listener function will be removed'); } return this; diff --git a/src/geometry/GeometryCollection.js b/src/geometry/GeometryCollection.js index c01dabb74e..ef8e8cec10 100644 --- a/src/geometry/GeometryCollection.js +++ b/src/geometry/GeometryCollection.js @@ -5,7 +5,7 @@ import Coordinate from '../geo/Coordinate'; import PointExtent from '../geo/PointExtent'; import Extent from '../geo/Extent'; import Geometry from './Geometry'; -import Browser from '../core/Browser'; +import GlobalConfig from '../GlobalConfig'; const TEMP_EXTENT = new PointExtent(); @@ -290,7 +290,7 @@ class GeometryCollection extends Geometry { continue; } if (isSelf(geometry)) { - if (!Browser.isTest) { + if (!GlobalConfig.isTest) { console.error(geometry, ' is GeometryCollection sub class,it Cannot be placed in GeometryCollection'); } continue; diff --git a/src/map/Map.DomEvents.js b/src/map/Map.DomEvents.js index 0b63c070dc..b89dafe307 100644 --- a/src/map/Map.DomEvents.js +++ b/src/map/Map.DomEvents.js @@ -1,4 +1,4 @@ -import Browser from '../core/Browser'; +import GlobalConfig from '../GlobalConfig'; import { now, extend } from '../core/util'; import { addDomEvent, @@ -223,7 +223,7 @@ Map.include(/** @lends Map.prototype */ { } const clickTimeThreshold = this.options['clickTimeThreshold']; const type = e.type; - if (isMoveEvent(type) && !Browser.isTest && isMousemoveEventBlocked(this, this.options['mousemoveThrottleTime'])) { + if (isMoveEvent(type) && !GlobalConfig.isTest && isMousemoveEventBlocked(this, this.options['mousemoveThrottleTime'])) { return; } const isMouseDown = type === 'mousedown' || (type === 'touchstart' && (!e.touches || e.touches.length === 1)); diff --git a/src/map/handler/Map.GeometryEvents.js b/src/map/handler/Map.GeometryEvents.js index eaa74983fe..3d1a51f448 100644 --- a/src/map/handler/Map.GeometryEvents.js +++ b/src/map/handler/Map.GeometryEvents.js @@ -3,7 +3,7 @@ import { on, off, getEventContainerPoint, preventDefault, stopPropagation, isMov import Handler from '../../handler/Handler'; import Geometry from '../../geometry/Geometry'; import Map from '../Map'; -import Browser from '../../core/Browser'; +import GlobalConfig from '../../GlobalConfig'; const EVENTS = /** @@ -205,7 +205,7 @@ class MapGeometryEventsHandler extends Handler { } let oneMoreEvent = null; const eventType = type || domEvent.type; - if (isMoveEvent(eventType) && !Browser.isTest && isMousemoveEventBlocked(this, map.options['mousemoveThrottleTime'])) { + if (isMoveEvent(eventType) && !GlobalConfig.isTest && isMousemoveEventBlocked(this, map.options['mousemoveThrottleTime'])) { stopPropagation(domEvent); return; } diff --git a/test/SpecCommon.js b/test/SpecCommon.js index f699fba811..f5d40e2506 100644 --- a/test/SpecCommon.js +++ b/test/SpecCommon.js @@ -107,7 +107,7 @@ function COMMON_CREATE_MAP(center, baseLayer, options) { if (baseLayer) { option.baseLayer = baseLayer; } - maptalks.Browser.isTest = true; + maptalks.Globalconfig.isTest = true; var map = new maptalks.Map(container, option); return { 'container': container,