def testDialogs(self): import robofab.interface.all.dialogs dialogModuleName = robofab.interface.all.dialogs.platformApplicationModuleName application = robofab.interface.all.dialogs.application if application is None and dialogModuleName == "dialogs_mac_vanilla": # in vanilla, but not in a host application, run with executeVanillaTest print print "I'm running these tests with executeVanillaTest" from vanilla.test.testTools import executeVanillaTest executeVanillaTest(DialogRunner) else: print print "I'm running these tests natively in" DialogRunner()
setDefault("DrawBotAnimateIcon", self.w.animateIcon.get()) setDefault("DrawBotCheckForUpdatesAtStartup", self.w.checkForUpdates.get()) setDefault("shouldOpenUntitledFile", self.w.shouldOpenUntitledFile.get()) setDefault("DrawBotAddToolbar", self.w.showToolbar.get()) def anitmateIconCallback(self, sender): self.setToDefaults() NSApp().delegate().sheduleIconTimer() def checkNowCallback(self, sender): from drawBot.updater import Updater oldValue = getDefault("DrawBotCheckForUpdatesAtStartup", True) setDefault("DrawBotCheckForUpdatesAtStartup", True) updater = Updater(self.w) if not updater.needsUpdate: self.showMessage( "You have the latest version!", "DrawBot %s is currently the newest version" % updater.__version__) setDefault("DrawBotCheckForUpdatesAtStartup", oldValue) def show(self): self.w.show() if __name__ == "__main__": from vanilla.test.testTools import executeVanillaTest executeVanillaTest(PreferencesController)
obj = getter(self.object, name) childObj = self.__class__(name, obj, self.object, setter) self._childRefs[child] = childObj return childObj def getDoc(self): doc = inspect.getdoc(self.object) if doc: return doc return None def __len__(self): return len(self.children) if __name__ == "__main__": import vanilla testObject = vanilla class TestWindow(): def __init__(self): self.w = vanilla.Window((400, 400), "inspect object browser %s" % testObject, minSize=(100, 100)) self.w.b = ObjectBrowser((0, 0, -0, -0), testObject) self.w.open() from vanilla.test.testTools import executeVanillaTest executeVanillaTest(TestWindow)
self.w.open() def openTestCallback(self, sender): title = sender.getTitle() if title == "Windows": WindowTest() elif title == "Geometry": from vanilla.test.testGeometry import TestGeometry TestGeometry() elif title == "Text": TextTest(self.w.drawGrid.get()) elif title == "Buttons": ButtonTest(self.w.drawGrid.get()) elif title == "List": ListTest(self.w.drawGrid.get()) elif title == "Browser": BrowserTest(self.w.drawGrid.get()) elif title == "Views": ViewTest(self.w.drawGrid.get()) elif title == "Toolbar": ToolbarTest(self.w.drawGrid.get()) elif title == "Misc.": MiscTest(self.w.drawGrid.get()) elif title == "SplitView": TestSplitView(self.w.drawGrid.get()) if __name__ == "__main__": from vanilla.test.testTools import executeVanillaTest executeVanillaTest(Test)
# Stack 4 yellow = AppKit.NSColor.colorWithCalibratedRed_green_blue_alpha_( 1, 1, 0, 0.75) stack4Views = [ dict(view=stack2, width=">=100"), dict(view=vanilla.Box("auto", fillColor=yellow), height=">=50, <=100"), dict(view=stack3, height=30) ] stack4 = vanilla.VerticalStackView("auto", views=stack4Views, spacing=10, edgeInsets=(0, 0, 0, 0)) self.w.stack = stack4 metrics = dict(margin=15) rules = [ "H:|-margin-[stack]-margin-|", "V:|-margin-[stack]-margin-|", ] self.w.addAutoPosSizeRules(rules, metrics) self.w.open() if __name__ == "__main__": import vanilla from vanilla.test.testTools import executeVanillaTest executeVanillaTest(TestStackView)
"NewFont" : mojo.roboFont.NewFont, }) class PseudoUTF8Output(object): softspace = 0 def __init__(self, writemethod): self._write = writemethod def write(self, s): if not isinstance(s, unicode): s = s.decode("utf-8", "replace") self._write(s) def writelines(self, lines): for line in lines: self.write(line) def flush(self): pass def isatty(self): return True if __name__ == "__main__": from vanilla.test.testTools import executeVanillaTest executeVanillaTest(PyREPLWindow)
# ------------------- # Interpreter Support # ------------------- class PseudoUTF8Output(object): softspace = 0 def __init__(self, writemethod): self._write = writemethod def write(self, s): if not isinstance(s, unicode): s = s.decode("utf-8", "replace") self._write(s) def writelines(self, lines): for line in lines: self.write(line) def flush(self): pass def isatty(self): return True if __name__ == "__main__": from vanilla.test.testTools import executeVanillaTest executeVanillaTest(PyInterpreterWindow)
def getDoc(self): doc = inspect.getdoc(self.object) if doc: return doc return None def __len__(self): return len(self.children) if __name__ == "__main__": import vanilla testObject = vanilla class TestWindow(): def __init__(self): self.w = vanilla.Window((400, 400), "inspect object browser %s" %testObject, minSize=(100, 100)) self.w.b = ObjectBrowser((0, 0, -0, -0), testObject) self.w.open() from vanilla.test.testTools import executeVanillaTest executeVanillaTest(TestWindow)
"CurrentGlyph": mojo.roboFont.CurrentGlyph, "OpenFont": mojo.roboFont.OpenFont, "NewFont": mojo.roboFont.NewFont, }) class PseudoUTF8Output(object): softspace = 0 def __init__(self, writemethod): self._write = writemethod def write(self, s): self._write(s) def writelines(self, lines): for line in lines: self.write(line) def flush(self): pass def isatty(self): return True if __name__ == "__main__": from vanilla.test.testTools import executeVanillaTest executeVanillaTest(PyREPLWindow)
] return cells def appendRowButtonCallback(self, sender): row = self._makeRow() self.w.gridView.appendRow(row) def insertRowButtonCallback(self, sender): row = self._makeRow() self.w.gridView.insertRow(self.rowCount, row) def removeRowButtonCallback(self, sender): if self.w.gridView.getRowCount() <= self.rowCount: # not a limitation of GridView, just a limitation of this test print("can't delete one of the main rows") else: self.w.gridView.removeRow(self.rowCount) def moveRowButtonCallback(self, sender): self.w.gridView.moveRow(0, 1) def showRowButtonCallback(self, sender): visible = self.w.gridView.rowIsVisible(1) self.w.gridView.showRow(1, not visible) if __name__ == "__main__": import vanilla from vanilla.test.testTools import executeVanillaTest executeVanillaTest(TestGridView)
self.w.animateIcon.set(getDefault("DrawBotAnimateIcon", True)) self.w.checkForUpdates.set(getDefault("DrawBotCheckForUpdatesAtStartup", True)) self.w.syntaxColors.getFromDefaults() def setToDefaults(self, sender=None): setDefault("DrawBotClearOutput", self.w.clearOutPut.get()) setDefault("DrawButLiveUpdateStdoutStderr", self.w.liveOutPut.get()) setDefault("DrawBotAnimateIcon", self.w.animateIcon.get()) setDefault("DrawBotCheckForUpdatesAtStartup", self.w.checkForUpdates.get()) def anitmateIconCallback(self, sender): self.setToDefaults() NSApp().delegate().sheduleIconTimer() def checkNowCallback(self, sender): from drawBot.updater import Updater oldValue = getDefault("DrawBotCheckForUpdatesAtStartup", True) setDefault("DrawBotCheckForUpdatesAtStartup", True) updater = Updater(self.w) if not updater.needsUpdate: self.showMessage("You have the latest version!", "DrawBot %s is currently the newest version" % updater.__version__) setDefault("DrawBotCheckForUpdatesAtStartup", oldValue) def show(self): self.w.show() if __name__ == "__main__": from vanilla.test.testTools import executeVanillaTest executeVanillaTest(PreferencesController)
print(e) print("Exception in user code:") print('-' * 60) traceback.print_exc(file=sys.stdout) print('-' * 60) sys.stdout.flush() def windowCloseCallback(self, sender): print('windowCloseCallback') print(self.settingsDict) saveSettings(self.settingsDict) sys.stdout.flush() def luxButtonCallback(self, sender): try: logLux(self) except Exception as e: print(e) print("Exception in user code:") print('-' * 60) traceback.print_exc(file=sys.stdout) print('-' * 60) sys.stdout.flush() if __name__ == "__main__": executeVanillaTest(MyInterface)