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

def main():
    startApplication("sasview")
    clickButton(waitForObject(":groupBox.cmdLoad_QPushButton"))
    waitForObjectItem(":stackedWidget.listView_QListView", "test")
    doubleClickItem(":stackedWidget.listView_QListView", "test", 38, 14, 0, Qt.LeftButton)
    waitForObjectItem(":stackedWidget.listView_QListView", "1d\\_data")
    doubleClickItem(":stackedWidget.listView_QListView", "1d\\_data", 19, 6, 0, Qt.LeftButton)
    waitForObjectItem(":stackedWidget.listView_QListView", "cyl\\_400\\_20\\.txt")
    doubleClickItem(":stackedWidget.listView_QListView", "cyl\\_400\\_20\\.txt", 78, 7, 0, Qt.LeftButton)
    
    mouseClick(waitForObject(":groupBox_6.cbCategory_QComboBox_2"), 170, 13, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":groupBox_6.cbCategory_QComboBox_2", "Cylinder"), 137, 10, 0, Qt.LeftButton)
        
    clickButton(waitForObject(":groupBox_3.cmdNew_QPushButton"))
    snooze(3)
    test.compare(waitForObjectExists(":qt_workspacechild.Graph1_QWorkspaceTitleBar").visible, True)
    test.compare(str(waitForObjectExists(":qt_workspacechild.Graph1_QWorkspaceTitleBar").windowTitle), "Graph1")
    test.vp("VP1")
    #mouseDrag(waitForObject(":qt_workspacechild.Graph1_QWorkspaceTitleBar"), 631, 15, 675, 0, 1, Qt.LeftButton)
    
    #mouseClick(waitForObject(":groupBox_6.cbModel_QComboBox_2"), 85, 13, 0, Qt.LeftButton)
    mouseClick(waitForObject(":groupBox_6.cbModel_QComboBox_3"), 79, 11, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":groupBox_6.cbModel_QComboBox_3", "cylinder"), 67, 2, 0, Qt.LeftButton)
    #mouseClick(waitForObjectItem(":groupBox_6.cbModel_QComboBox_2", "cylinder"), 80, 5, 0, Qt.LeftButton)
    #mouseClick(waitForObject(":groupBox_6.cbModel_QComboBox_2"), 63, 9, 0, Qt.LeftButton)
    #mouseClick(waitForObjectItem(":groupBox_6.cbModel_QComboBox_2", "cylinder"), 51, 6, 0, Qt.LeftButton)
    
    waitForObjectItem(":groupBox_6.lstParams_QTreeView_2", "scale")
    clickItem(":groupBox_6.lstParams_QTreeView_2", "scale", 9, 10, 0, Qt.LeftButton)
    clickButton(waitForObject(":groupBox.cmdSendTo_QPushButton"))
    waitForObjectItem(":groupBox_6.lstParams_QTreeView_2", "background")
    clickItem(":groupBox_6.lstParams_QTreeView_2", "background", 7, 9, 0, Qt.LeftButton)
    clickButton(waitForObject(":FittingWidgetUI.cmdFit_QPushButton"))
    snooze(1)
    test.compare(str(waitForObjectExists(":groupBox_9.lblChi2Value_QLabel_2").text), "54.058")
    test.compare(waitForObjectExists(":groupBox_9.lblChi2Value_QLabel_2").visible, True)
    test.compare(waitForObjectExists(":qt_workspacechild.Graph4_QWorkspaceTitleBar").visible, True)
    test.compare(str(waitForObjectExists(":qt_workspacechild.Graph4_QWorkspaceTitleBar").windowTitle), "Graph4")
    test.compare(waitForObjectExists(":qt_workspacechild_FigureCanvasQTAgg_3").visible, True)
    test.compare(waitForObjectExists(":qt_workspacechild.Graph3_QWorkspaceTitleBar").visible, True)
    test.compare(str(waitForObjectExists(":qt_workspacechild.Graph3_QWorkspaceTitleBar").windowTitle), "Graph3")
    sendEvent("QMouseEvent", waitForObject(":qt_workspacechild.Customize_QLabel"), QEvent.MouseButtonPress, 283, 24, Qt.LeftButton, 1, 0)
    sendEvent("QMouseEvent", waitForObject(":qt_workspacechild.Customize_QLabel_2"), QEvent.MouseButtonRelease, 283, 24, Qt.LeftButton, 0, 0)
    test.compare(waitForObjectExists(":qt_workspacechild.Graph2_QWorkspaceTitleBar").visible, True)
    test.compare(str(waitForObjectExists(":qt_workspacechild.Graph2_QWorkspaceTitleBar").windowTitle), "Graph2")
    sendEvent("QMouseEvent", waitForObject(":qt_workspacechild.Graph3_QWorkspaceTitleBar_2"), QEvent.MouseButtonPress, 96, 22, Qt.LeftButton, 1, 0)
    sendEvent("QMouseEvent", waitForObject(":qt_workspacechild.Graph3_QWorkspaceTitleBar_3"), QEvent.MouseButtonRelease, 96, 22, Qt.LeftButton, 0, 0)
    test.vp("VP2")
    test.compare(waitForObjectExists(":lstParams.0.72485_QModelIndex").text, "0.72485")
    test.compare(waitForObjectExists(":lstParams.0.2338_QModelIndex").text, "0.2338")
    test.compare(waitForObjectExists(":groupBox_3.cbgraph_QComboBox").count, 3)
