モックを使ってテスト

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@7150 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-09-02 18:33:59 +00:00
parent c628aaed86
commit f7a2eb06c5

View File

@ -0,0 +1,36 @@
utils.include(baseURL+'../../content/treestyletab/treestyletab.js');
utils.include(baseURL+'../../content/treestyletab/treestyletabbrowser_autoHide.js');
var autoHide;
var owner;
function setUp()
{
owner = new Mock('owner mock');
Mock.expect(TreeStyleTabBrowserAutoHide.prototype, 'init', []);
autoHide = new TreeStyleTabBrowserAutoHide(owner);
}
function tearDown()
{
}
function test_fireStateChangingEvent()
{
var shown = Math.random() + Date.now() + 'expanded';
var state = Math.random() + Date.now() + 'expanded';
owner.browser = new Mock('browser');
owner.browser.expect('dispatchEvent', TypeOf(Ci.nsIDOMEvent))
.then(function(aEvent) {
assert.equals(shown, aEvent.shown);
assert.equals(state, aEvent.state);
});
Mock.expectGet(autoHide, 'expanded', shown);
Mock.expectGet(autoHide, 'state', state);
autoHide.fireStateChangingEvent();
}