MCPcopy Create free account
hub / github.com/e2b-dev/surf / testSmallTargetEdgeCases

Function testSmallTargetEdgeCases

lib/streaming/resolution.test.ts:294–480  ·  view source on GitHub ↗

* Special test case focused on the edge case that might be causing the reported issue

()

Source from the content-addressed store, hash-verified

292 * Special test case focused on the edge case that might be causing the reported issue
293 */
294function testSmallTargetEdgeCases() {
295 // Create a set of problematic scenarios to test
296 const scenarios = [
297 {
298 name: "4K with tiny target",
299 resolution: [3840, 2160],
300 targets: [
301 { name: "1px dot", position: [10, 10], size: 1 },
302 { name: "2px dot", position: [20, 20], size: 2 },
303 { name: "3px dot", position: [30, 30], size: 3 },
304 ],
305 },
306 {
307 name: "5K with sub-pixel rounding test",
308 resolution: [5120, 2880],
309 targets: Array.from({ length: 10 }, (_, i) => ({
310 name: `Point ${i + 1}`,
311 position: [i * 10 + 5, i * 10 + 5],
312 size: 3,
313 })),
314 },
315 {
316 name: "Fractional scale factor test",
317 resolution: [2560, 1600], // Likely to produce fractional scale factor
318 targets: Array.from({ length: 10 }, (_, i) => ({
319 name: `Point ${i + 1}`,
320 position: [Math.floor((2560 * i) / 10), Math.floor((1600 * i) / 10)],
321 size: 5,
322 })),
323 },
324 ];
325
326 // Run detailed test on each scenario
327 for (const scenario of scenarios) {
328 console.log(`\n=== ${scenario.name} ===`);
329 const mockSandbox = new MockSandbox() as any;
330 const scaler = new ResolutionScaler(mockSandbox, scenario.resolution);
331
332 console.log(
333 `Resolution: ${scenario.resolution[0]}x${scenario.resolution[1]}`
334 );
335 console.log(
336 `Scaled to: ${scaler.getScaledResolution()[0]}x${
337 scaler.getScaledResolution()[1]
338 }`
339 );
340 console.log(`Scale factor: ${scaler.getScaleFactor().toFixed(6)}`);
341
342 // Analyze exact vs. rounded scale factors
343 const originalResolution = scenario.resolution;
344 const scaledResolution = scaler.getScaledResolution();
345
346 const exactXScaleFactor = scaledResolution[0] / originalResolution[0];
347 const exactYScaleFactor = scaledResolution[1] / originalResolution[1];
348 const actualScaleFactor = scaler.getScaleFactor();
349
350 console.log(`\nExact X scale factor: ${exactXScaleFactor.toFixed(6)}`);
351 console.log(`Exact Y scale factor: ${exactYScaleFactor.toFixed(6)}`);

Callers 1

runResolutionScalerTestsFunction · 0.85

Calls 4

getScaledResolutionMethod · 0.95
getScaleFactorMethod · 0.95
scaleToModelSpaceMethod · 0.95
scaleToOriginalSpaceMethod · 0.95

Tested by

no test coverage detected