michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Tests that the locale category is shown if there are no locale packs michael@0: // installed but some are pending install michael@0: michael@0: var gManagerWindow; michael@0: var gCategoryUtilities; michael@0: var gProvider; michael@0: var gInstallProperties = [{ michael@0: name: "Locale Category Test", michael@0: type: "locale" michael@0: }]; michael@0: var gInstall; michael@0: var gExpectedCancel = false; michael@0: var gTestInstallListener = { michael@0: onInstallStarted: function(aInstall) { michael@0: check_hidden(false); michael@0: }, michael@0: michael@0: onInstallEnded: function(aInstall) { michael@0: check_hidden(false); michael@0: run_next_test(); michael@0: }, michael@0: michael@0: onInstallCancelled: function(aInstall) { michael@0: ok(gExpectedCancel, "Should expect install cancel"); michael@0: check_hidden(false); michael@0: run_next_test(); michael@0: }, michael@0: michael@0: onInstallFailed: function(aInstall) { michael@0: ok(false, "Did not expect onInstallFailed"); michael@0: } michael@0: }; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: gProvider = new MockProvider(); michael@0: michael@0: open_manager("addons://list/extension", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: michael@0: function end_test() { michael@0: close_manager(gManagerWindow, function() { michael@0: finish(); michael@0: }); michael@0: } michael@0: michael@0: function check_hidden(aExpectedHidden) { michael@0: var hidden = !gCategoryUtilities.isTypeVisible("locale"); michael@0: is(hidden, aExpectedHidden, "Should have correct hidden state"); michael@0: } michael@0: michael@0: // Tests that a non-active install does not make the locale category show michael@0: add_test(function() { michael@0: check_hidden(true); michael@0: gInstall = gProvider.createInstalls(gInstallProperties)[0]; michael@0: gInstall.addTestListener(gTestInstallListener); michael@0: check_hidden(true); michael@0: run_next_test(); michael@0: }); michael@0: michael@0: // Test that restarting the add-on manager with a non-active install michael@0: // does not cause the locale category to show michael@0: add_test(function() { michael@0: restart_manager(gManagerWindow, null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: check_hidden(true); michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: // Test that installing the install shows the locale category michael@0: add_test(function() { michael@0: gInstall.install(); michael@0: }); michael@0: michael@0: // Test that restarting the add-on manager does not cause the locale category michael@0: // to become hidden michael@0: add_test(function() { michael@0: restart_manager(gManagerWindow, null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: check_hidden(false); michael@0: michael@0: gExpectedCancel = true; michael@0: gInstall.cancel(); michael@0: }); michael@0: }); michael@0: