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

def main():
    startApplication("sasview")
    clickTab(waitForObject(":Data Explorer.DataLoadWidget_DataExplorerWindow"), "Theory")
    mouseClick(waitForObject(":groupBox_6.cbCategory_QComboBox"), 39, 4, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":groupBox_6.cbCategory_QComboBox", "Cylinder"), 28, 3, 0, Qt.LeftButton)
    
    mouseClick(waitForObject(":groupBox_6.cbModel_QComboBox_2"), 43, 7, 0, Qt.LeftButton)
    mouseClick(waitForObjectItem(":groupBox_6.cbModel_QComboBox_2", "core\\_shell\\_bicelle\\_elliptical"), 49, 7, 0, Qt.LeftButton)
   
    
    clickButton(waitForObject(":FittingWidgetUI.cmdPlot_QPushButton_2"))
    snooze(2)
    waitForObjectItem(":groupBox_2.freezeView_QTreeView", "M1 [core\\_shell\\_bicelle\\_elliptical]")
    clickItem(":groupBox_2.freezeView_QTreeView", "M1 [core\\_shell\\_bicelle\\_elliptical]", 64, 7, 0, Qt.LeftButton)
    openItemContextMenu(waitForObject(":groupBox_2.freezeView_QTreeView"), "M1 [core\\_shell\\_bicelle\\_elliptical]", 64, 7, 0)
    activateItem(waitForObjectItem(":MainWindow_QMenu", "Data Info"))
    test.compare(waitForObjectExists(":Data Info: M1 [core_shell_bicelle_elliptical]_QTextEdit").visible, True)
    test.compare(str(waitForObjectExists(":Data Info: M1 [core_shell_bicelle_elliptical]_QTextEdit").html), "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">File:            M1 [core_shell_bicelle_elliptical]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Title:           M1 [core_shell_bicelle_elliptical]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Run:             []</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">SESANS:          None</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Instrument:      </p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Sample:</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   ID:           </p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Transmission: None</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Thickness:    None [mm]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Temperature:  None [None]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Position:     x = None	y = None	z = None [mm]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Orientation:  x = None	y = None	z = None [degree]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Details:</p>\n<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Source:</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Radiation:    None</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Shape:        None</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Wavelength:   None [A]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Waveln_min:   None [nm]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Waveln_max:   None [nm]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Waveln_spread:None [percent]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Beam_size:    x = None	y = None	z = None [mm]</p>\n<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Data:</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Type:         Data1D</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   X-axis:       \\rm{Q}	[A^{-1}]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Y-axis:       \\rm{Intensity}	[cm^{-1}]</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">   Length:       25</p>\n<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Data Min Max:</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">X_min = 0.005:  X_max = 0.1</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Y_min = 4.61789496717:  Y_max = 369.191266886</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">dY_min = 0.0:  dY_max = 0.0</p>\n<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Data Points:</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">&lt;index&gt; 	&lt;X&gt; 	&lt;Y&gt; 	&lt;dY&gt; 	&lt;dX&gt;</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">0 	0.005 	369.191266886 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">1 	0.00895833333333 	343.924827081 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">2 	0.0129166666667 	308.166416117 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">3 	0.016875 	266.135593911 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">4 	0.0208333333333 	222.25367246 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">5 	0.0247916666667 	180.3727708 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">6 	0.02875 	143.231604481 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">7 	0.0327083333333 	112.237202971 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">8 	0.0366666666667 	87.5714529475 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">9 	0.040625 	68.5337536767 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">10 	0.0445833333333 	53.9821956025 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">11 	0.0485416666667 	42.7358242671 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">12 	0.0525 	33.8423092996 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">13 	0.0564583333333 	26.6782576019 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">14 	0.0604166666667 	20.9089451174 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">15 	0.064375 	16.3710952381 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">16 	0.0683333333333 	12.9486265509 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">17 	0.0722916666667 	10.4915918121 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">18 	0.07625 	8.79599248628 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">19 	0.0802083333333 	7.63199964682 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">20 	0.0841666666667 	6.79137560771 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">21 	0.088125 	6.12490078577 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">22 	0.0920833333333 	5.55319597067 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">23 	0.0960416666667 	5.05104882551 	0.0 	0.0</p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">24 	0.1 	4.61789496717 	0.0 	0.0</p>\n<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>")
    test.compare(str(waitForObjectExists(":Data Info: M1 [core_shell_bicelle_elliptical]_QTextEdit").windowTitle), "Data Info: M1 [core_shell_bicelle_elliptical]")
    sendEvent("QCloseEvent", waitForObject(":Data Info: M1 [core_shell_bicelle_elliptical]_QTextEdit"))
    openItemContextMenu(waitForObject(":groupBox_2.freezeView_QTreeView"), "M1 [core\\_shell\\_bicelle\\_elliptical]", 209, 15, 0)
    activateItem(waitForObjectItem(":MainWindow_QMenu", "Save As"))
    test.compare(str(waitForObjectExists(":QFileDialog_QFileDialog").windowTitle), "Save As")
    test.compare(waitForObjectExists(":QFileDialog_QFileDialog").visible, True)
    test.compare(str(waitForObjectExists(":QFileDialog.fileTypeCombo_QComboBox").currentText), "Text files (*.txt)")
    test.compare(waitForObjectExists(":QFileDialog.fileTypeCombo_QComboBox").enabled, True)
    test.compare(waitForObjectExists(":fileNameEdit_QLineEdit").enabled, True)
    test.compare(str(waitForObjectExists(":fileNameEdit_QLineEdit").text), "M1 [core_shell_bicelle_elliptical]_out.txt")
    clickButton(waitForObject(":QFileDialog.Cancel_QPushButton"))
    openItemContextMenu(waitForObject(":groupBox_2.freezeView_QTreeView"), "M1 [core\\_shell\\_bicelle\\_elliptical]", 138, 10, 0)
    activateItem(waitForObjectItem(":MainWindow_QMenu", "Quick Plot"))
    test.compare(waitForObjectExists(":Plot M1 [core_shell_bicelle_elliptical]_FigureCanvasQTAgg").visible, True)
    test.compare(waitForObjectExists(":Plot M1 [core_shell_bicelle_elliptical]_FigureCanvasQTAgg").enabled, True)
    test.compare(str(waitForObjectExists(":Plot M1 [core_shell_bicelle_elliptical]_Plotter").windowTitle), "Plot M1 [core_shell_bicelle_elliptical]")
    test.compare(waitForObjectExists(":Plot M1 [core_shell_bicelle_elliptical]_Plotter").visible, True)
    test.vp("VP1")
    sendEvent("QCloseEvent", waitForObject(":Plot M1 [core_shell_bicelle_elliptical]_Plotter"))
