# -*- coding: utf-8 -*-

def main():
    startApplication("sasview")
    activateItem(waitForObjectItem(":MainWindow.menubar_QMenuBar", "Help"))
    activateItem(waitForObjectItem(":MainWindow.menuHelp_QMenu", "Documentation"))
    test.compare(waitForObjectExists(":_QWebView").visible, True)
    test.compare(str(waitForObjectExists(":_QWebView").title), "SasView Documentation Index — SasView 4.1.0 documentation")
    test.compare(waitForObjectExists(":_QWebView").enabled, True)
    sendEvent("QCloseEvent", waitForObject(":_QWebView"))
    activateItem(waitForObjectItem(":MainWindow.menubar_QMenuBar", "Help"))
    #activateItem(waitForObjectItem(":MainWindow.menuHelp_QMenu", "Tutorial"))
    activateItem(waitForObjectItem(":MainWindow.menuHelp_QMenu", "Acknowledge"))
    test.compare(str(waitForObjectExists(":Acknowledgements_Acknowledgements").windowTitle), "Acknowledging SasView")
    test.compare(waitForObjectExists(":Acknowledgements_Acknowledgements").enabled, True)
    test.compare(waitForObjectExists(":Acknowledgements_Acknowledgements").visible, True)
    sendEvent("QCloseEvent", waitForObject(":Acknowledgements_Acknowledgements"))
    activateItem(waitForObjectItem(":MainWindow.menubar_QMenuBar", "Help"))
    activateItem(waitForObjectItem(":MainWindow.menuHelp_QMenu", "About"))
    test.compare(waitForObjectExists(":AboutUI_AboutBox").enabled, True)
    test.compare(str(waitForObjectExists(":AboutUI_AboutBox").windowTitle), "About")
    test.compare(waitForObjectExists(":AboutUI_AboutBox").visible, True)
    sendEvent("QCloseEvent", waitForObject(":AboutUI_AboutBox"))
    activateItem(waitForObjectItem(":MainWindow.menubar_QMenuBar", "Help"))
    activateItem(waitForObjectItem(":MainWindow.menuHelp_QMenu", "Check for update"))
    snooze(2)
    mouseDrag(waitForObject(":MainWindow_MainSasViewWindow"), 714, 1015, 1, -89, 1, Qt.LeftButton)
    test.compare(str(waitForObjectExists(":MainWindow.Version 4.1.2 is available! _QLabel").text), "Version 4.1.2 is available! ")

