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

def main():
    startApplication("sasview")
    mouseClick(waitForObject(":groupBox_6.cbCategory_QComboBox_2"), 114, 12, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":groupBox_6.cbCategory_QComboBox_2", "Lamellae"), 103, 10, 0, Qt.LeftButton)
    clickButton(waitForObject(":FittingWidgetUI.cmdPlot_QPushButton_2"))
    snooze(1)
    clickButton(waitForObject(":FittingWidgetUI.cmdPlot_QPushButton_2"))
    snooze(2)
    
    openContextMenu(waitForObject(":qt_workspacechild_FigureCanvasQTAgg"), 221, 184, 0)
    activateItem(waitForObjectItem(":MainWindow_QMenu", "Change Scale"))
    sendEvent("QMoveEvent", waitForObject(":scalePropertiesUI_ScaleProperties"), 685, 470, 973, 489)
    test.compare(waitForObjectExists(":qt_workspacechild.cbX_QComboBox").count, 6)
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbX_QComboBox").currentText), "log10(x)")
    test.compare(waitForObjectExists(":qt_workspacechild.cbX_QComboBox").currentIndex, 4)
    test.compare(waitForObjectExists(":qt_workspacechild.cbX_QComboBox").visible, True)
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbY_QComboBox").currentText), "log10(y)")
    test.compare(waitForObjectExists(":qt_workspacechild.cbY_QComboBox").currentIndex, 7)
    test.compare(waitForObjectExists(":qt_workspacechild.cbView_QComboBox").currentIndex, 0)
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbView_QComboBox").currentText), "--")
    mouseClick(waitForObject(":qt_workspacechild.cbView_QComboBox"), 93, 7, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":qt_workspacechild.cbView_QComboBox", "Linear y vs x"), 93, 6, 0, Qt.LeftButton)
    clickButton(waitForObject(":qt_workspacechild.OK_QPushButton"))
    test.vp("VP1")
    snooze(2)
    #sendEvent("QMouseEvent", waitForObject(":qt_workspacechild_FigureCanvasQTAgg_2"), QEvent.MouseButtonPress, 351, 209, Qt.RightButton, 2, 0)
    #sendEvent("QMouseEvent", waitForObject(":qt_workspacechild_FigureCanvasQTAgg"), QEvent.MouseButtonRelease, 351, 209, Qt.RightButton, 0, 0)
    
    openContextMenu(waitForObject(":qt_workspacechild_FigureCanvasQTAgg"), 351, 209, 0)
    activateItem(waitForObjectItem(":MainWindow_QMenu", "Change Scale"))
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbView_QComboBox").currentText), "Linear y vs x")
    mouseClick(waitForObject(":qt_workspacechild.cbView_QComboBox"), 21, 10, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":qt_workspacechild.cbView_QComboBox", "Guinier lny vs x^(2)"), 27, 5, 0, Qt.LeftButton)
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbX_QComboBox").currentText), "x^(2)")
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbY_QComboBox").currentText), "ln(y)")
    mouseClick(waitForObject(":qt_workspacechild.cbView_QComboBox"), 95, 9, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":qt_workspacechild.cbView_QComboBox", "XS Guinier ln(y*x) vs x^(2)"), 70, 4, 0, Qt.LeftButton)
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbX_QComboBox").currentText), "x^(2)")
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbY_QComboBox").currentText), "ln(y*x)")
    mouseClick(waitForObject(":qt_workspacechild.cbView_QComboBox"), 83, 5, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":qt_workspacechild.cbView_QComboBox", "Porod y*x^(4) vs x^(4)"), 57, 1, 0, Qt.LeftButton)
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbX_QComboBox").currentText), "x^(4)")
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbY_QComboBox").currentText), "y*x^(4)")
    mouseClick(waitForObject(":qt_workspacechild.cbView_QComboBox"), 94, 5, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":qt_workspacechild.cbView_QComboBox", "Kratky y*x^(2) vs x"), 58, 6, 0, Qt.LeftButton)
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbX_QComboBox").currentText), "x")
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbY_QComboBox").currentText), "y*x^(2)")
    mouseClick(waitForObject(":qt_workspacechild.cbView_QComboBox"), 74, 3, 0, Qt.LeftButton)
    mouseClick(waitForObject(":qt_workspacechild.cbView_QComboBox"), 74, 3, 0, Qt.LeftButton)
    mouseClick(waitForObject(":qt_workspacechild.cbX_QComboBox"), 31, 8, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":qt_workspacechild.cbX_QComboBox", "log10(x^(4))"), 42, 5, 0, Qt.LeftButton)
    mouseClick(waitForObject(":qt_workspacechild.cbY_QComboBox"), 45, 10, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":qt_workspacechild.cbY_QComboBox", "y"), 30, 8, 0, Qt.LeftButton)
    test.compare(str(waitForObjectExists(":qt_workspacechild.cbView_QComboBox").currentText), "--")
    mouseClick(waitForObject(":qt_workspacechild.cbX_QComboBox"), 67, 9, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":qt_workspacechild.cbX_QComboBox", "log10(x)"), 56, 5, 0, Qt.LeftButton)
    mouseClick(waitForObject(":qt_workspacechild.cbY_QComboBox"), 42, 12, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":qt_workspacechild.cbY_QComboBox", "log10(y)"), 55, 8, 0, Qt.LeftButton)
    clickButton(waitForObject(":qt_workspacechild.OK_QPushButton"))
    test.vp("VP2")
