def test_addonCompat_addonRequiresNewFeature(self): """Test an addon that has just been developed, requiring an API feature introduced in the current release.""" addon = mockAddon(minAPIVersion=latestVersionTuple, lastTestedAPIVersion=latestVersionTuple) nvda_current, nvda_backwardsCompatTo = latestVersionTuple, previousVersionTuple self.assertTrue(addonVersionCheck.hasAddonGotRequiredSupport(addon, nvda_current)) self.assertTrue(addonVersionCheck.isAddonTested(addon, nvda_backwardsCompatTo)) self.assertTrue(addonVersionCheck.isAddonCompatible(addon, nvda_current, nvda_backwardsCompatTo))
def test_addonCompat_testedAgainstLastBackwardsCompatVersion(self): """Test an addon has been maintained and tested against the backwardsCompatTo version.""" addon = mockAddon(minAPIVersion=oldVersionTuple, lastTestedAPIVersion=previousVersionTuple) nvda_current, nvda_backwardsCompatTo = latestVersionTuple, previousVersionTuple self.assertTrue(addonVersionCheck.hasAddonGotRequiredSupport(addon, nvda_current)) self.assertTrue(addonVersionCheck.isAddonTested(addon, nvda_backwardsCompatTo)) self.assertTrue(addonVersionCheck.isAddonCompatible(addon, nvda_current, nvda_backwardsCompatTo))
def refreshAddonsList(self, activeIndex=0): self.addonsList.DeleteAllItems() self.curAddons = [] anyAddonIncompatible = False for addon in addonHandler.getAvailableAddons(): self.addonsList.Append( (addon.manifest['summary'], self.getAddonStatus(addon), addon.manifest['version'], addon.manifest['author'])) self.curAddons.append(addon) anyAddonIncompatible = ( anyAddonIncompatible # once we find one incompatible addon we don't need to continue or not addonVersionCheck.isAddonCompatible( addon, currentAPIVersion=addonAPIVersion.CURRENT, backwardsCompatToVersion=addonAPIVersion.BACK_COMPAT_TO)) self.incompatAddonsButton.Enable(anyAddonIncompatible) # select the given active addon or the first addon if not given curAddonsLen = len(self.curAddons) if curAddonsLen > 0: if activeIndex == -1: activeIndex = curAddonsLen - 1 elif activeIndex < 0 or activeIndex >= curAddonsLen: activeIndex = 0 self.addonsList.Select(activeIndex, on=1) self.addonsList.SetItemState(activeIndex, wx.LIST_STATE_FOCUSED, wx.LIST_STATE_FOCUSED) else: self.aboutButton.Disable() self.helpButton.Disable() self.removeButton.Disable()
def refreshAddonsList(self,activeIndex=0): self.addonsList.DeleteAllItems() self.curAddons=[] anyAddonIncompatible = False for addon in addonHandler.getAvailableAddons(): self.addonsList.Append(( addon.manifest['summary'], self.getAddonStatus(addon), addon.manifest['version'], addon.manifest['author'] )) self.curAddons.append(addon) anyAddonIncompatible = ( anyAddonIncompatible # once we find one incompatible addon we don't need to continue or not addonVersionCheck.isAddonCompatible( addon, currentAPIVersion=addonAPIVersion.CURRENT, backwardsCompatToVersion=addonAPIVersion.BACK_COMPAT_TO ) ) self.incompatAddonsButton.Enable(anyAddonIncompatible) # select the given active addon or the first addon if not given curAddonsLen=len(self.curAddons) if curAddonsLen>0: if activeIndex==-1: activeIndex=curAddonsLen-1 elif activeIndex<0 or activeIndex>=curAddonsLen: activeIndex=0 self.addonsList.Select(activeIndex,on=1) self.addonsList.SetItemState(activeIndex,wx.LIST_STATE_FOCUSED,wx.LIST_STATE_FOCUSED) else: self.aboutButton.Disable() self.helpButton.Disable() self.removeButton.Disable()
def refreshAddonsList(self, activeIndex=0): self.addonsList = [] self.curActivatedAddons = [] self.curAddons = [] for addon in sorted(addonHandler.getAvailableAddons(), key=lambda a: strxfrm(a.manifest['summary'])): addonIncompatible = (not addonVersionCheck.isAddonCompatible( addon, currentAPIVersion=addonAPIVersion.CURRENT, backwardsCompatToVersion=addonAPIVersion.BACK_COMPAT_TO)) if addonIncompatible or addon.isBlocked: continue if (addon.isRunning and not addon.isPendingDisable or addon.isDisabled and (not addon.isPendingDisable or not globalVars.appArgs.disableAddons)): self.curAddons.append(addon) for addon in self.curAddons: state = addon.isRunning if state: index = self.curAddons.index(addon) self.curActivatedAddons.append(index) self.addonsListBox.AppendItems( [x.manifest["summary"] for x in self.curAddons]) self.addonsListBox.SetCheckedItems(self.curActivatedAddons) self.addonsListBox.SetSelection(0)
def test_addonCompat_attemptingToUseAddonRequiringNewAPIFeaturesWithOldNVDA(self): """Test that is considered incompatible if a user tries to install a new addon with an old version of NVDA""" # addon requires API features in the future release addon = mockAddon(minAPIVersion=nextVersionTuple, lastTestedAPIVersion=nextVersionTuple) nvda_current, nvda_backwardsCompatTo = latestVersionTuple, previousVersionTuple self.assertFalse(addonVersionCheck.hasAddonGotRequiredSupport(addon, latestVersionTuple)) self.assertTrue(addonVersionCheck.isAddonTested(addon, latestVersionTuple)) self.assertFalse(addonVersionCheck.isAddonCompatible(addon, nvda_current, nvda_backwardsCompatTo))
def test_addonCompat_lastTestedAgainstNowNoLongerSupportedAPIVersion(self): """Test an addon is considered incompatible if the backwards compatible to version is moved forward for an addon that has not been updated.""" addon = mockAddon(minAPIVersion=oldVersionTuple, lastTestedAPIVersion=previousVersionTuple) # NVDA backwards compatible to has been moved forward one version: nvda_current, nvda_backwardsCompatTo = latestVersionTuple, latestVersionTuple self.assertTrue(addonVersionCheck.hasAddonGotRequiredSupport(addon, nvda_current)) self.assertFalse(addonVersionCheck.isAddonTested(addon, nvda_backwardsCompatTo)) self.assertFalse(addonVersionCheck.isAddonCompatible(addon, nvda_current, nvda_backwardsCompatTo))
def onListItemSelected(self, evt): index=evt.GetIndex() addon=self.curAddons[index] if index>=0 else None # #3090: Change toggle button label to indicate action to be taken if clicked. if addon is not None: # Translators: The label for a button in Add-ons Manager dialog to enable or disable the selected add-on. self.enableDisableButton.SetLabel(_("&Enable add-on") if not self._shouldDisable(addon) else _("&Disable add-on")) self.aboutButton.Enable(addon is not None and not addon.isPendingRemove) self.helpButton.Enable(bool(addon is not None and not addon.isPendingRemove and addon.getDocFilePath())) self.enableDisableButton.Enable( addon is not None and not addon.isPendingRemove and addonVersionCheck.isAddonCompatible(addon) ) self.removeButton.Enable(addon is not None and not addon.isPendingRemove)
def onListItemSelected(self, evt): index=evt.GetIndex() addon=self.curAddons[index] if index>=0 else None # #3090: Change toggle button label to indicate action to be taken if clicked. if addon is not None: # Translators: The label for a button in Add-ons Manager dialog to enable or disable the selected add-on. self.enableDisableButton.SetLabel(_("&Enable add-on") if not self._shouldDisable(addon) else _("&Disable add-on")) self.aboutButton.Enable(addon is not None and not addon.isPendingRemove) self.helpButton.Enable(bool(addon is not None and not addon.isPendingRemove and addon.getDocFilePath())) self.enableDisableButton.Enable( addon is not None and not addon.isPendingRemove and addonVersionCheck.isAddonCompatible(addon) ) self.removeButton.Enable(addon is not None and not addon.isPendingRemove)