| 305 | | </html> |
|---|
| 306 | | <html> |
|---|
| 307 | | <head> |
|---|
| 308 | | <script src="../../lib/OpenLayers.js"></script> |
|---|
| 309 | | <script type="text/javascript"> |
|---|
| 310 | | |
|---|
| 311 | | var geometry = null, node = null; |
|---|
| 312 | | |
|---|
| 313 | | function test_VML_constructor(t) { |
|---|
| 314 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 315 | | t.plan(0); |
|---|
| 316 | | return; |
|---|
| 317 | | } |
|---|
| 318 | | |
|---|
| 319 | | t.plan(1); |
|---|
| 320 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 321 | | t.ok(r instanceof OpenLayers.Renderer.VML, "new OpenLayers.Renderer.VML returns VML object" ); |
|---|
| 322 | | } |
|---|
| 323 | | |
|---|
| 324 | | function test_VML_destroy(t) { |
|---|
| 325 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 326 | | t.plan(0); |
|---|
| 327 | | return; |
|---|
| 328 | | } |
|---|
| 329 | | |
|---|
| 330 | | t.plan(1); |
|---|
| 331 | | |
|---|
| 332 | | var g_Destroy = false; |
|---|
| 333 | | |
|---|
| 334 | | OpenLayers.Renderer.Elements.prototype._destroy = |
|---|
| 335 | | OpenLayers.Renderer.Elements.prototype.destroy; |
|---|
| 336 | | |
|---|
| 337 | | OpenLayers.Renderer.prototype.destroy = function() { |
|---|
| 338 | | g_Destroy = true; |
|---|
| 339 | | } |
|---|
| 340 | | |
|---|
| 341 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 342 | | r.destroy(); |
|---|
| 343 | | |
|---|
| 344 | | t.eq(g_Destroy, true, "OpenLayers.Renderer.Elements.destroy() called"); |
|---|
| 345 | | |
|---|
| 346 | | OpenLayers.Renderer.prototype.destroy = |
|---|
| 347 | | OpenLayers.Renderer.prototype._destroy; |
|---|
| 348 | | } |
|---|
| 349 | | |
|---|
| 350 | | function test_VML_setextent(t) { |
|---|
| 351 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 352 | | t.plan(0); |
|---|
| 353 | | return; |
|---|
| 354 | | } |
|---|
| 355 | | |
|---|
| 356 | | t.plan(3); |
|---|
| 357 | | |
|---|
| 358 | | OpenLayers.Renderer.Elements.prototype._setExtent = |
|---|
| 359 | | OpenLayers.Renderer.Elements.prototype.setExtent; |
|---|
| 360 | | |
|---|
| 361 | | var g_SetExtent = false; |
|---|
| 362 | | OpenLayers.Renderer.Elements.prototype.setExtent = function() { |
|---|
| 363 | | g_SetExtent = true; |
|---|
| 364 | | } |
|---|
| 365 | | |
|---|
| 366 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 367 | | r.map = { |
|---|
| 368 | | getResolution: function() { |
|---|
| 369 | | return 0.5; |
|---|
| 370 | | } |
|---|
| 371 | | } |
|---|
| 372 | | |
|---|
| 373 | | var extent = new OpenLayers.Bounds(1,2,3,4); |
|---|
| 374 | | r.setExtent(extent); |
|---|
| 375 | | |
|---|
| 376 | | t.eq(g_SetExtent, true, "Elements.setExtent() called"); |
|---|
| 377 | | |
|---|
| 378 | | t.ok(r.root.coordorigin == "2,8", "coordorigin is correct"); |
|---|
| 379 | | t.ok(r.root.coordsize == "4,-4", "coordsize is correct"); |
|---|
| 380 | | |
|---|
| 381 | | OpenLayers.Renderer.Elements.prototype.setExtent = |
|---|
| 382 | | OpenLayers.Renderer.Elements.prototype._setExtent; |
|---|
| 383 | | } |
|---|
| 384 | | |
|---|
| 385 | | function test_VML_setsize(t) { |
|---|
| 386 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 387 | | t.plan(0); |
|---|
| 388 | | return; |
|---|
| 389 | | } |
|---|
| 390 | | |
|---|
| 391 | | t.plan(4); |
|---|
| 392 | | |
|---|
| 393 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 394 | | |
|---|
| 395 | | var size = new OpenLayers.Size(1,2); |
|---|
| 396 | | r.setSize(size); |
|---|
| 397 | | t.eq(r.rendererRoot.style.width, "1px", "rendererRoot width is correct"); |
|---|
| 398 | | t.eq(r.rendererRoot.style.height, "2px", "rendererRoot height is correct"); |
|---|
| 399 | | |
|---|
| 400 | | t.eq(r.root.style.width, "100%", "root width is correct"); |
|---|
| 401 | | t.eq(r.root.style.height, "100%", "root height is correct"); |
|---|
| 402 | | } |
|---|
| 403 | | |
|---|
| 404 | | function test_VML_drawpoint(t) { |
|---|
| 405 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 406 | | t.plan(0); |
|---|
| 407 | | return; |
|---|
| 408 | | } |
|---|
| 409 | | |
|---|
| 410 | | t.plan(1); |
|---|
| 411 | | |
|---|
| 412 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 413 | | |
|---|
| 414 | | var properDraw = false; |
|---|
| 415 | | var g_Radius = null; |
|---|
| 416 | | r.drawCircle = function(n, g, r) { |
|---|
| 417 | | properDraw = true; |
|---|
| 418 | | g_Radius = 1; |
|---|
| 419 | | } |
|---|
| 420 | | r.drawPoint(); |
|---|
| 421 | | |
|---|
| 422 | | t.ok(properDraw && g_Radius == 1, "drawPoint called drawCircle with radius set to 1"); |
|---|
| 423 | | } |
|---|
| 424 | | |
|---|
| 425 | | function test_VML_drawcircle(t) { |
|---|
| 426 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 427 | | t.plan(0); |
|---|
| 428 | | return; |
|---|
| 429 | | } |
|---|
| 430 | | |
|---|
| 431 | | t.plan(4); |
|---|
| 432 | | |
|---|
| 433 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 434 | | r.resolution = 0.5; |
|---|
| 435 | | |
|---|
| 436 | | var node = document.createElement('div'); |
|---|
| 437 | | |
|---|
| 438 | | var geometry = { |
|---|
| 439 | | x: 1, |
|---|
| 440 | | y: 2 |
|---|
| 441 | | } |
|---|
| 442 | | |
|---|
| 443 | | var radius = 3; |
|---|
| 444 | | r.drawCircle(node, geometry, radius); |
|---|
| 445 | | |
|---|
| 446 | | t.eq(node.style.left, '-1px', "left is correct"); |
|---|
| 447 | | t.eq(node.style.top, '1px', "top is correct"); |
|---|
| 448 | | t.eq(node.style.width, (2 * radius) + "px", "width is correct"); |
|---|
| 449 | | t.eq(node.style.height, (2 * radius) + "px", "height is correct"); |
|---|
| 450 | | } |
|---|
| 451 | | |
|---|
| 452 | | function test_VML_drawlinestring(t) { |
|---|
| 453 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 454 | | t.plan(0); |
|---|
| 455 | | return; |
|---|
| 456 | | } |
|---|
| 457 | | |
|---|
| 458 | | t.plan(1); |
|---|
| 459 | | |
|---|
| 460 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 461 | | |
|---|
| 462 | | g_DrawLine = false; |
|---|
| 463 | | r.drawLine = function(c) { |
|---|
| 464 | | g_DrawLine = true; |
|---|
| 465 | | } |
|---|
| 466 | | |
|---|
| 467 | | r.drawLineString(node, geometry); |
|---|
| 468 | | |
|---|
| 469 | | t.ok(g_DrawLine, "drawLine is called"); |
|---|
| 470 | | } |
|---|
| 471 | | |
|---|
| 472 | | function test_VML_drawlinearring(t) { |
|---|
| 473 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 474 | | t.plan(0); |
|---|
| 475 | | return; |
|---|
| 476 | | } |
|---|
| 477 | | |
|---|
| 478 | | t.plan(1); |
|---|
| 479 | | |
|---|
| 480 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 481 | | |
|---|
| 482 | | g_DrawLine = false; |
|---|
| 483 | | r.drawLine = function(c) { |
|---|
| 484 | | g_DrawLine = true; |
|---|
| 485 | | } |
|---|
| 486 | | |
|---|
| 487 | | r.drawLinearRing(node, geometry); |
|---|
| 488 | | |
|---|
| 489 | | t.ok(g_DrawLine, "drawLine is called"); |
|---|
| 490 | | } |
|---|
| 491 | | |
|---|
| 492 | | function test_VML_drawline(t) { |
|---|
| 493 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 494 | | t.plan(0); |
|---|
| 495 | | return; |
|---|
| 496 | | } |
|---|
| 497 | | |
|---|
| 498 | | t.plan(8); |
|---|
| 499 | | |
|---|
| 500 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 501 | | r.resolution = 0.5; |
|---|
| 502 | | |
|---|
| 503 | | var node = document.createElement('div'); |
|---|
| 504 | | |
|---|
| 505 | | var geometry = { |
|---|
| 506 | | components: [{ |
|---|
| 507 | | x: 1, |
|---|
| 508 | | y: 2 |
|---|
| 509 | | },{ |
|---|
| 510 | | x: 3, |
|---|
| 511 | | y: 4 |
|---|
| 512 | | }], |
|---|
| 513 | | getBounds: function() { |
|---|
| 514 | | return new OpenLayers.Bounds(5,6,7,8); |
|---|
| 515 | | } |
|---|
| 516 | | }; |
|---|
| 517 | | |
|---|
| 518 | | r.drawLine(node, geometry, true); |
|---|
| 519 | | t.ok(node.path.indexOf("x") != -1, "path attribute is correct when passed closeLine = true"); |
|---|
| 520 | | |
|---|
| 521 | | |
|---|
| 522 | | r.drawLine(node, geometry, false); |
|---|
| 523 | | t.eq(node.path, "m 2,4 l 6,8 l e", "path attribute is correct"); |
|---|
| 524 | | t.eq(node.style.left, "10px", "node.style.left is correct"); |
|---|
| 525 | | t.eq(node.style.top, "16px", "node.style.top is correct"); |
|---|
| 526 | | t.eq(node.style.width, "4px", "node.style.width is correct"); |
|---|
| 527 | | t.eq(node.style.height, "4px", "node.style.height is correct"); |
|---|
| 528 | | t.eq(node.coordorigin, "10 16", "node.coordorigin is correct"); |
|---|
| 529 | | t.eq(node.coordsize, "4 4", "node.coordsize is correct"); |
|---|
| 530 | | } |
|---|
| 531 | | |
|---|
| 532 | | function test_VML_drawpolygon(t) { |
|---|
| 533 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 534 | | t.plan(0); |
|---|
| 535 | | return; |
|---|
| 536 | | } |
|---|
| 537 | | |
|---|
| 538 | | t.plan(2); |
|---|
| 539 | | |
|---|
| 540 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 541 | | r.resolution = 0.5; |
|---|
| 542 | | |
|---|
| 543 | | g_SetNodeDimension = false; |
|---|
| 544 | | r.setNodeDimension = function(){ |
|---|
| 545 | | g_SetNodeDimension = true; |
|---|
| 546 | | }; |
|---|
| 547 | | |
|---|
| 548 | | var node = document.createElement('div'); |
|---|
| 549 | | |
|---|
| 550 | | var linearRing = { |
|---|
| 551 | | components: [{ |
|---|
| 552 | | x: 1, |
|---|
| 553 | | y: 2 |
|---|
| 554 | | },{ |
|---|
| 555 | | x: 3, |
|---|
| 556 | | y: 4 |
|---|
| 557 | | }] |
|---|
| 558 | | }; |
|---|
| 559 | | var linearRing2 = { |
|---|
| 560 | | components: [{ |
|---|
| 561 | | x: 5, |
|---|
| 562 | | y: 6 |
|---|
| 563 | | },{ |
|---|
| 564 | | x: 7, |
|---|
| 565 | | y: 8 |
|---|
| 566 | | }] |
|---|
| 567 | | }; |
|---|
| 568 | | var geometry = { |
|---|
| 569 | | components: [linearRing, linearRing2] |
|---|
| 570 | | }; |
|---|
| 571 | | r.drawPolygon(node, geometry, true); |
|---|
| 572 | | t.ok(g_SetNodeDimension, "setNodeDimension is called"); |
|---|
| 573 | | t.eq(node.path, "m 2,4 l 6,8 x m 10,12 l 14,16 x e", "path attribute is correct"); |
|---|
| 574 | | } |
|---|
| 575 | | |
|---|
| 576 | | function test_VML_drawrectangle(t) { |
|---|
| 577 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 578 | | t.plan(0); |
|---|
| 579 | | return; |
|---|
| 580 | | } |
|---|
| 581 | | |
|---|
| 582 | | t.plan(4); |
|---|
| 583 | | |
|---|
| 584 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 585 | | r.resolution = 0.5; |
|---|
| 586 | | |
|---|
| 587 | | var node = document.createElement('div'); |
|---|
| 588 | | |
|---|
| 589 | | var geometry = { |
|---|
| 590 | | x: 1, |
|---|
| 591 | | y: 2, |
|---|
| 592 | | width: 3, |
|---|
| 593 | | height: 4 |
|---|
| 594 | | } |
|---|
| 595 | | |
|---|
| 596 | | r.drawRectangle(node, geometry); |
|---|
| 597 | | |
|---|
| 598 | | t.eq(node.style.left, "2px", "node.style.left is correct"); |
|---|
| 599 | | t.eq(node.style.top, "4px", "node.style.top is correct"); |
|---|
| 600 | | t.eq(node.style.width, "6px", "node.style.width is correct"); |
|---|
| 601 | | t.eq(node.style.height, "8px", "node.style.height is correct"); |
|---|
| 602 | | } |
|---|
| 603 | | |
|---|
| 604 | | |
|---|
| 605 | | </script> |
|---|
| 606 | | </head> |
|---|
| 607 | | <body> |
|---|
| 608 | | <div id="map" style="width:500px;height:550px"></div> |
|---|
| 609 | | </body> |
|---|
| 610 | | </html> |
|---|
| 611 | | <html> |
|---|
| 612 | | <head> |
|---|
| 613 | | <script src="../../lib/OpenLayers.js"></script> |
|---|
| 614 | | <script type="text/javascript"> |
|---|
| 615 | | |
|---|
| 616 | | var geometry = null, node = null; |
|---|
| 617 | | |
|---|
| 618 | | function test_VML_constructor(t) { |
|---|
| 619 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 620 | | t.plan(0); |
|---|
| 621 | | return; |
|---|
| 622 | | } |
|---|
| 623 | | |
|---|
| 624 | | t.plan(1); |
|---|
| 625 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 626 | | t.ok(r instanceof OpenLayers.Renderer.VML, "new OpenLayers.Renderer.VML returns VML object" ); |
|---|
| 627 | | } |
|---|
| 628 | | |
|---|
| 629 | | function test_VML_destroy(t) { |
|---|
| 630 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 631 | | t.plan(0); |
|---|
| 632 | | return; |
|---|
| 633 | | } |
|---|
| 634 | | |
|---|
| 635 | | t.plan(1); |
|---|
| 636 | | |
|---|
| 637 | | var g_Destroy = false; |
|---|
| 638 | | |
|---|
| 639 | | OpenLayers.Renderer.Elements.prototype._destroy = |
|---|
| 640 | | OpenLayers.Renderer.Elements.prototype.destroy; |
|---|
| 641 | | |
|---|
| 642 | | OpenLayers.Renderer.prototype.destroy = function() { |
|---|
| 643 | | g_Destroy = true; |
|---|
| 644 | | } |
|---|
| 645 | | |
|---|
| 646 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 647 | | r.destroy(); |
|---|
| 648 | | |
|---|
| 649 | | t.eq(g_Destroy, true, "OpenLayers.Renderer.Elements.destroy() called"); |
|---|
| 650 | | |
|---|
| 651 | | OpenLayers.Renderer.prototype.destroy = |
|---|
| 652 | | OpenLayers.Renderer.prototype._destroy; |
|---|
| 653 | | } |
|---|
| 654 | | |
|---|
| 655 | | function test_VML_setextent(t) { |
|---|
| 656 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 657 | | t.plan(0); |
|---|
| 658 | | return; |
|---|
| 659 | | } |
|---|
| 660 | | |
|---|
| 661 | | t.plan(3); |
|---|
| 662 | | |
|---|
| 663 | | OpenLayers.Renderer.Elements.prototype._setExtent = |
|---|
| 664 | | OpenLayers.Renderer.Elements.prototype.setExtent; |
|---|
| 665 | | |
|---|
| 666 | | var g_SetExtent = false; |
|---|
| 667 | | OpenLayers.Renderer.Elements.prototype.setExtent = function() { |
|---|
| 668 | | g_SetExtent = true; |
|---|
| 669 | | } |
|---|
| 670 | | |
|---|
| 671 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 672 | | r.map = { |
|---|
| 673 | | getResolution: function() { |
|---|
| 674 | | return 0.5; |
|---|
| 675 | | } |
|---|
| 676 | | } |
|---|
| 677 | | |
|---|
| 678 | | var extent = new OpenLayers.Bounds(1,2,3,4); |
|---|
| 679 | | r.setExtent(extent); |
|---|
| 680 | | |
|---|
| 681 | | t.eq(g_SetExtent, true, "Elements.setExtent() called"); |
|---|
| 682 | | |
|---|
| 683 | | t.ok(r.root.coordorigin == "2,8", "coordorigin is correct"); |
|---|
| 684 | | t.ok(r.root.coordsize == "4,-4", "coordsize is correct"); |
|---|
| 685 | | |
|---|
| 686 | | OpenLayers.Renderer.Elements.prototype.setExtent = |
|---|
| 687 | | OpenLayers.Renderer.Elements.prototype._setExtent; |
|---|
| 688 | | } |
|---|
| 689 | | |
|---|
| 690 | | function test_VML_setsize(t) { |
|---|
| 691 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 692 | | t.plan(0); |
|---|
| 693 | | return; |
|---|
| 694 | | } |
|---|
| 695 | | |
|---|
| 696 | | t.plan(4); |
|---|
| 697 | | |
|---|
| 698 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 699 | | |
|---|
| 700 | | var size = new OpenLayers.Size(1,2); |
|---|
| 701 | | r.setSize(size); |
|---|
| 702 | | t.eq(r.rendererRoot.style.width, "1px", "rendererRoot width is correct"); |
|---|
| 703 | | t.eq(r.rendererRoot.style.height, "2px", "rendererRoot height is correct"); |
|---|
| 704 | | |
|---|
| 705 | | t.eq(r.root.style.width, "100%", "root width is correct"); |
|---|
| 706 | | t.eq(r.root.style.height, "100%", "root height is correct"); |
|---|
| 707 | | } |
|---|
| 708 | | |
|---|
| 709 | | function test_VML_drawpoint(t) { |
|---|
| 710 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 711 | | t.plan(0); |
|---|
| 712 | | return; |
|---|
| 713 | | } |
|---|
| 714 | | |
|---|
| 715 | | t.plan(1); |
|---|
| 716 | | |
|---|
| 717 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 718 | | |
|---|
| 719 | | var properDraw = false; |
|---|
| 720 | | var g_Radius = null; |
|---|
| 721 | | r.drawCircle = function(n, g, r) { |
|---|
| 722 | | properDraw = true; |
|---|
| 723 | | g_Radius = 1; |
|---|
| 724 | | } |
|---|
| 725 | | r.drawPoint(); |
|---|
| 726 | | |
|---|
| 727 | | t.ok(properDraw && g_Radius == 1, "drawPoint called drawCircle with radius set to 1"); |
|---|
| 728 | | } |
|---|
| 729 | | |
|---|
| 730 | | function test_VML_drawcircle(t) { |
|---|
| 731 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 732 | | t.plan(0); |
|---|
| 733 | | return; |
|---|
| 734 | | } |
|---|
| 735 | | |
|---|
| 736 | | t.plan(4); |
|---|
| 737 | | |
|---|
| 738 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 739 | | r.resolution = 0.5; |
|---|
| 740 | | |
|---|
| 741 | | var node = document.createElement('div'); |
|---|
| 742 | | |
|---|
| 743 | | var geometry = { |
|---|
| 744 | | x: 1, |
|---|
| 745 | | y: 2 |
|---|
| 746 | | } |
|---|
| 747 | | |
|---|
| 748 | | var radius = 3; |
|---|
| 749 | | r.drawCircle(node, geometry, radius); |
|---|
| 750 | | |
|---|
| 751 | | t.eq(node.style.left, '-1px', "left is correct"); |
|---|
| 752 | | t.eq(node.style.top, '1px', "top is correct"); |
|---|
| 753 | | t.eq(node.style.width, (2 * radius) + "px", "width is correct"); |
|---|
| 754 | | t.eq(node.style.height, (2 * radius) + "px", "height is correct"); |
|---|
| 755 | | } |
|---|
| 756 | | |
|---|
| 757 | | function test_VML_drawlinestring(t) { |
|---|
| 758 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 759 | | t.plan(0); |
|---|
| 760 | | return; |
|---|
| 761 | | } |
|---|
| 762 | | |
|---|
| 763 | | t.plan(1); |
|---|
| 764 | | |
|---|
| 765 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 766 | | |
|---|
| 767 | | g_DrawLine = false; |
|---|
| 768 | | r.drawLine = function(c) { |
|---|
| 769 | | g_DrawLine = true; |
|---|
| 770 | | } |
|---|
| 771 | | |
|---|
| 772 | | r.drawLineString(node, geometry); |
|---|
| 773 | | |
|---|
| 774 | | t.ok(g_DrawLine, "drawLine is called"); |
|---|
| 775 | | } |
|---|
| 776 | | |
|---|
| 777 | | function test_VML_drawlinearring(t) { |
|---|
| 778 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 779 | | t.plan(0); |
|---|
| 780 | | return; |
|---|
| 781 | | } |
|---|
| 782 | | |
|---|
| 783 | | t.plan(1); |
|---|
| 784 | | |
|---|
| 785 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 786 | | |
|---|
| 787 | | g_DrawLine = false; |
|---|
| 788 | | r.drawLine = function(c) { |
|---|
| 789 | | g_DrawLine = true; |
|---|
| 790 | | } |
|---|
| 791 | | |
|---|
| 792 | | r.drawLinearRing(node, geometry); |
|---|
| 793 | | |
|---|
| 794 | | t.ok(g_DrawLine, "drawLine is called"); |
|---|
| 795 | | } |
|---|
| 796 | | |
|---|
| 797 | | function test_VML_drawline(t) { |
|---|
| 798 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 799 | | t.plan(0); |
|---|
| 800 | | return; |
|---|
| 801 | | } |
|---|
| 802 | | |
|---|
| 803 | | t.plan(8); |
|---|
| 804 | | |
|---|
| 805 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 806 | | r.resolution = 0.5; |
|---|
| 807 | | |
|---|
| 808 | | var node = document.createElement('div'); |
|---|
| 809 | | |
|---|
| 810 | | var geometry = { |
|---|
| 811 | | components: [{ |
|---|
| 812 | | x: 1, |
|---|
| 813 | | y: 2 |
|---|
| 814 | | },{ |
|---|
| 815 | | x: 3, |
|---|
| 816 | | y: 4 |
|---|
| 817 | | }], |
|---|
| 818 | | getBounds: function() { |
|---|
| 819 | | return new OpenLayers.Bounds(5,6,7,8); |
|---|
| 820 | | } |
|---|
| 821 | | }; |
|---|
| 822 | | |
|---|
| 823 | | r.drawLine(node, geometry, true); |
|---|
| 824 | | t.ok(node.path.indexOf("x") != -1, "path attribute is correct when passed closeLine = true"); |
|---|
| 825 | | |
|---|
| 826 | | |
|---|
| 827 | | r.drawLine(node, geometry, false); |
|---|
| 828 | | t.eq(node.path, "m 2,4 l 6,8 l e", "path attribute is correct"); |
|---|
| 829 | | t.eq(node.style.left, "10px", "node.style.left is correct"); |
|---|
| 830 | | t.eq(node.style.top, "16px", "node.style.top is correct"); |
|---|
| 831 | | t.eq(node.style.width, "4px", "node.style.width is correct"); |
|---|
| 832 | | t.eq(node.style.height, "4px", "node.style.height is correct"); |
|---|
| 833 | | t.eq(node.coordorigin, "10 16", "node.coordorigin is correct"); |
|---|
| 834 | | t.eq(node.coordsize, "4 4", "node.coordsize is correct"); |
|---|
| 835 | | } |
|---|
| 836 | | |
|---|
| 837 | | function test_VML_drawpolygon(t) { |
|---|
| 838 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 839 | | t.plan(0); |
|---|
| 840 | | return; |
|---|
| 841 | | } |
|---|
| 842 | | |
|---|
| 843 | | t.plan(2); |
|---|
| 844 | | |
|---|
| 845 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 846 | | r.resolution = 0.5; |
|---|
| 847 | | |
|---|
| 848 | | g_SetNodeDimension = false; |
|---|
| 849 | | r.setNodeDimension = function(){ |
|---|
| 850 | | g_SetNodeDimension = true; |
|---|
| 851 | | }; |
|---|
| 852 | | |
|---|
| 853 | | var node = document.createElement('div'); |
|---|
| 854 | | |
|---|
| 855 | | var linearRing = { |
|---|
| 856 | | components: [{ |
|---|
| 857 | | x: 1, |
|---|
| 858 | | y: 2 |
|---|
| 859 | | },{ |
|---|
| 860 | | x: 3, |
|---|
| 861 | | y: 4 |
|---|
| 862 | | }] |
|---|
| 863 | | }; |
|---|
| 864 | | var linearRing2 = { |
|---|
| 865 | | components: [{ |
|---|
| 866 | | x: 5, |
|---|
| 867 | | y: 6 |
|---|
| 868 | | },{ |
|---|
| 869 | | x: 7, |
|---|
| 870 | | y: 8 |
|---|
| 871 | | }] |
|---|
| 872 | | }; |
|---|
| 873 | | var geometry = { |
|---|
| 874 | | components: [linearRing, linearRing2] |
|---|
| 875 | | }; |
|---|
| 876 | | r.drawPolygon(node, geometry, true); |
|---|
| 877 | | t.ok(g_SetNodeDimension, "setNodeDimension is called"); |
|---|
| 878 | | t.eq(node.path, "m 2,4 l 6,8 x m 10,12 l 14,16 x e", "path attribute is correct"); |
|---|
| 879 | | } |
|---|
| 880 | | |
|---|
| 881 | | function test_VML_drawrectangle(t) { |
|---|
| 882 | | if (!OpenLayers.Renderer.VML.prototype.supported()) { |
|---|
| 883 | | t.plan(0); |
|---|
| 884 | | return; |
|---|
| 885 | | } |
|---|
| 886 | | |
|---|
| 887 | | t.plan(4); |
|---|
| 888 | | |
|---|
| 889 | | var r = new OpenLayers.Renderer.VML(document.body); |
|---|
| 890 | | r.resolution = 0.5; |
|---|
| 891 | | |
|---|
| 892 | | var node = document.createElement('div'); |
|---|
| 893 | | |
|---|
| 894 | | var geometry = { |
|---|
| 895 | | x: 1, |
|---|
| 896 | | y: 2, |
|---|
| 897 | | width: 3, |
|---|
| 898 | | height: 4 |
|---|
| 899 | | } |
|---|
| 900 | | |
|---|
| 901 | | r.drawRectangle(node, geometry); |
|---|
| 902 | | |
|---|
| 903 | | t.eq(node.style.left, "2px", "node.style.left is correct"); |
|---|
| 904 | | t.eq(node.style.top, "4px", "node.style.top is correct"); |
|---|
| 905 | | t.eq(node.style.width, "6px", "node.style.width is correct"); |
|---|
| 906 | | t.eq(node.style.height, "8px", "node.style.height is correct"); |
|---|
| 907 | | } |
|---|
| 908 | | |
|---|
| 909 | | |
|---|
| 910 | | </script> |
|---|
| 911 | | </head> |
|---|
| 912 | | <body> |
|---|
| 913 | | <div id="map" style="width:500px;height:550px"></div> |
|---|
| 914 | | </body> |
|---|
| 915 | | </html> |
|---|
| | 305 | </html> |