Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var callbackPass = chrome.test.callbackPass; | 5 var callbackPass = chrome.test.callbackPass; |
| 6 var callbackFail = chrome.test.callbackFail; | |
| 6 var defaultFuzzFactor = 1; | 7 var defaultFuzzFactor = 1; |
| 7 | 8 |
| 8 function assertFuzzyEq(expected, actual, fuzzFactor, message) { | 9 function assertFuzzyEq(expected, actual, fuzzFactor, message) { |
| 9 if (!message) { | 10 if (!message) { |
| 10 message = "Expected: " + expected + "; actual: " + actual + "; " | 11 message = "Expected: " + expected + "; actual: " + actual + "; " |
| 11 + "fuzzyFactor: " + fuzzFactor; | 12 + "fuzzyFactor: " + fuzzFactor; |
| 12 } | 13 } |
| 13 | 14 |
| 14 chrome.test.assertTrue(actual - fuzzFactor <= expected | 15 chrome.test.assertTrue(actual - fuzzFactor <= expected |
| 15 && actual + fuzzFactor >= expected, message); | 16 && actual + fuzzFactor >= expected, message); |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 win.clearBadge(); | 553 win.clearBadge(); |
| 553 win.setBadgeIcon('non_square.png'); | 554 win.setBadgeIcon('non_square.png'); |
| 554 win.clearBadge(); | 555 win.clearBadge(); |
| 555 chrome.test.sendMessage( | 556 chrome.test.sendMessage( |
| 556 'WaitForRoundTrip', callbackPass(function(reply) {})); | 557 'WaitForRoundTrip', callbackPass(function(reply) {})); |
| 557 })); | 558 })); |
| 558 }, | 559 }, |
| 559 ]); | 560 ]); |
| 560 } | 561 } |
| 561 | 562 |
| 563 function testFrameColors() { | |
| 564 chrome.test.runTests([ | |
| 565 function testWithNoColor() { | |
| 566 chrome.app.window.create('test.html', callbackPass(function(win) { | |
| 567 chrome.test.assertEq(false, win.hasFrameColor); | |
| 568 win.close(); | |
| 569 })); | |
| 570 }, | |
| 571 | |
| 572 function testWithFrameNone() { | |
| 573 chrome.app.window.create('test.html', { | |
| 574 frame: 'none' | |
| 575 }, | |
| 576 callbackPass(function(win) { | |
| 577 chrome.test.assertEq(false, win.hasFrameColor); | |
| 578 win.close(); | |
| 579 })); | |
| 580 }, | |
| 581 | |
| 582 function testWithBlack() { | |
|
Matt Giuca
2014/02/18 06:03:18
I would prefer if one of these tests (black or whi
benwells
2014/02/18 07:47:25
As discussed, color parsing is unit tested.
| |
| 583 chrome.app.window.create('test.html', { | |
| 584 frameOptions: { | |
| 585 type: 'chrome', | |
| 586 color: '#000000' | |
| 587 } | |
| 588 }, | |
| 589 callbackPass(function(win) { | |
| 590 chrome.test.assertEq(true, win.hasFrameColor); | |
| 591 chrome.test.assertEq(-16777216, win.frameColor); | |
| 592 win.close(); | |
| 593 })); | |
| 594 }, | |
| 595 | |
| 596 function testWithWhite() { | |
| 597 chrome.app.window.create('test.html', { | |
| 598 frameOptions: { | |
| 599 color: '#FFFFFF' | |
| 600 } | |
| 601 }, | |
| 602 callbackPass(function(win) { | |
| 603 chrome.test.assertEq(true, win.hasFrameColor); | |
| 604 chrome.test.assertEq(-1, win.frameColor); | |
| 605 win.close(); | |
| 606 })); | |
| 607 }, | |
| 608 | |
| 609 function testWithWhiteShorthand() { | |
| 610 chrome.app.window.create('test.html', { | |
| 611 frameOptions: { | |
| 612 color: '#FFF' | |
| 613 } | |
| 614 }, | |
| 615 callbackPass(function(win) { | |
| 616 chrome.test.assertEq(true, win.hasFrameColor); | |
| 617 chrome.test.assertEq(-1, win.frameColor); | |
| 618 win.close(); | |
| 619 })); | |
| 620 }, | |
| 621 | |
| 622 function testWithFrameAndFrameOptions() { | |
| 623 chrome.app.window.create('test.html', { | |
| 624 frame: 'chrome', | |
| 625 frameOptions: { | |
| 626 color: '#FFF' | |
| 627 } | |
| 628 }, | |
| 629 callbackFail('Only one of frame and frameOptions can be supplied.')); | |
| 630 }, | |
| 631 | |
| 632 function testWithFrameNoneAndColor() { | |
| 633 chrome.app.window.create('test.html', { | |
| 634 frameOptions: { | |
| 635 type: 'none', | |
| 636 color: '#FFF' | |
| 637 } | |
| 638 }, | |
| 639 callbackFail('Windows with no frame cannot have a color.')); | |
| 640 }, | |
| 641 | |
| 642 function testWithInvalidColor() { | |
|
Matt Giuca
2014/02/18 06:03:18
Can you also test with an invalid string starting
| |
| 643 chrome.app.window.create('test.html', { | |
| 644 frameOptions: { | |
| 645 color: 'DontWorryBeHappy' | |
| 646 } | |
| 647 }, | |
| 648 callbackFail('The color specification could not be parsed.')); | |
| 649 } | |
| 650 ]); | |
| 651 } | |
| 652 | |
| 653 function testFrameColorsInStable() { | |
| 654 chrome.test.runTests([ | |
| 655 function testWithNoColor() { | |
| 656 chrome.app.window.create('test.html', callbackPass(function(win) { | |
| 657 chrome.test.assertEq(true, win.hasFrameColor); | |
| 658 chrome.test.assertEq(-1, win.frameColor); | |
| 659 win.close(); | |
| 660 })); | |
| 661 }, | |
| 662 | |
| 663 function testWithOptionsGivesError() { | |
| 664 chrome.app.window.create('test.html', { | |
| 665 frameOptions: { | |
| 666 color: '#FFF' | |
| 667 } | |
| 668 }, | |
| 669 callbackFail('frameOptions is only available in dev channel.')); | |
| 670 } | |
| 671 ]); | |
| 672 } | |
| 673 | |
| 562 chrome.app.runtime.onLaunched.addListener(function() { | 674 chrome.app.runtime.onLaunched.addListener(function() { |
| 563 chrome.test.sendMessage('Launched', function(reply) { | 675 chrome.test.sendMessage('Launched', function(reply) { |
| 564 window[reply](); | 676 window[reply](); |
| 565 }); | 677 }); |
| 566 }); | 678 }); |
| OLD | NEW |