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

def main():
    startApplication("sasview")
    clickButton(waitForObject(":groupBox.cmdLoad_QPushButton"))
    waitForObjectItem(":stackedWidget.listView_QListView", "test")
    doubleClickItem(":stackedWidget.listView_QListView", "test", 30, 10, 0, Qt.LeftButton)
    waitForObjectItem(":stackedWidget.listView_QListView", "1d\\_data")
    doubleClickItem(":stackedWidget.listView_QListView", "1d\\_data", 34, 11, 0, Qt.LeftButton)
    waitForObjectItem(":stackedWidget.listView_QListView", "cyl\\_400\\_20\\.txt")
    clickItem(":stackedWidget.listView_QListView", "cyl\\_400\\_20\\.txt", 69, 10, 0, Qt.LeftButton)
    clickButton(waitForObject(":buttonBox.Open_QPushButton"))
    clickButton(waitForObject(":groupBox.cmdLoad_QPushButton"))
    waitForObjectItem(":stackedWidget.listView_QListView", "cyl\\_400\\_40\\.txt")
    clickItem(":stackedWidget.listView_QListView", "cyl\\_400\\_40\\.txt", 99, 9, 0, Qt.LeftButton)
    waitForObjectItem(":stackedWidget.listView_QListView", "cyl\\_testdata\\.txt")
    clickItem(":stackedWidget.listView_QListView", "cyl\\_testdata\\.txt", 74, 11, 67108864, Qt.LeftButton)
    clickButton(waitForObject(":buttonBox.Open_QPushButton"))
    snooze(1)
    test.compare(waitForObjectExists(":treeView.cyl_400_20.txt_QModelIndex").checkState, "checked")
    test.compare(waitForObjectExists(":treeView.cyl_400_20.txt_QModelIndex").text, "cyl_400_20.txt")
    test.compare(waitForObjectExists(":treeView.cyl_400_40.txt_QModelIndex").checkState, "checked")
    test.compare(waitForObjectExists(":treeView.cyl_400_40.txt_QModelIndex").text, "cyl_400_40.txt")
    test.compare(waitForObjectExists(":treeView.cyl_testdata.txt_QModelIndex").text, "cyl_testdata.txt")
    test.compare(waitForObjectExists(":treeView.cyl_testdata.txt_QModelIndex").checkState, "checked")
    mouseClick(waitForObject(":groupBox.cbSelect_QComboBox"), 87, 9, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":groupBox.cbSelect_QComboBox", "Unselect all"), 64, 7, 0, Qt.LeftButton)
    test.compare(waitForObjectExists(":treeView.cyl_400_20.txt_QModelIndex").selected, False)
    test.compare(waitForObjectExists(":treeView.cyl_400_40.txt_QModelIndex").selected, False)
    test.compare(waitForObjectExists(":treeView.cyl_testdata.txt_QModelIndex").selected, False)
    mouseClick(waitForObjectItem(":groupBox.cbSelect_QComboBox", "Select all 1D"), 54, 10, 0, Qt.LeftButton)
    test.compare(waitForObjectExists(":treeView.cyl_400_20.txt_QModelIndex").checkState, "checked")
    test.compare(waitForObjectExists(":treeView.cyl_400_40.txt_QModelIndex").checkState, "checked")
    test.compare(waitForObjectExists(":treeView.cyl_testdata.txt_QModelIndex").checkState, "checked")
    mouseClick(waitForObjectItem(":groupBox.cbSelect_QComboBox", "Unselect all 2D"), 68, 2, 0, Qt.LeftButton)
    test.compare(waitForObjectExists(":treeView.cyl_400_20.txt_QModelIndex").checkState, "checked")
