]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - tools/src/tools/configtool/standalone/wxwin/runtestsdlg.h
Initial revision
[karo-tx-redboot.git] / tools / src / tools / configtool / standalone / wxwin / runtestsdlg.h
1 //####COPYRIGHTBEGIN####
2 //
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5 //
6 // This program is part of the eCos host tools.
7 //
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
11 // any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16 // more details.
17 //
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 //
22 // ----------------------------------------------------------------------------
23 //
24 //####COPYRIGHTEND####
25 // runtestsdlg.cpp :
26 //
27 //===========================================================================
28 //#####DESCRIPTIONBEGIN####
29 //
30 // Author(s):   julians
31 // Contact(s):  julians
32 // Date:        2000/09/29
33 // Version:     $Id$
34 // Purpose:
35 // Description: Header file for ecRunTestsDialog
36 // Requires:
37 // Provides:
38 // See also:
39 // Known bugs:
40 // Usage:
41 //
42 //####DESCRIPTIONEND####
43 //
44 //===========================================================================
45
46 #ifndef _ECOS_RUNTESTSDLG_H_
47 #define _ECOS_RUNTESTSDLG_H_
48
49 #ifdef __GNUG__
50     #pragma interface "runtestsdlg.cpp"
51 #endif
52
53 #include "wx/notebook.h"
54 #include "wx/thread.h"
55
56 #include "eCosTest.h"
57 #include "Properties.h"
58
59 /*
60  * ecRunTestsTimer
61  * Just to force idle processing now and again while
62  * the tests are running
63  */
64
65 class ecRunTestsTimer: public wxTimer
66 {
67 public:
68     ecRunTestsTimer() {}
69
70     virtual void Notify() ;
71 };
72
73 //----------------------------------------------------------------------------
74 // ecRunTestsDialog
75 //----------------------------------------------------------------------------
76
77 class ecRunTestsExecutablesDialog;
78 class ecRunTestsOutputDialog;
79 class ecRunTestsSummaryDialog;
80
81 enum ecRunStatus { ecRunning, ecStopping, ecStopped };
82
83 #ifdef __WXGTK__
84 #define DWORD int
85 #endif
86
87 class ecRunTestsDialog: public wxDialog
88 {
89 DECLARE_CLASS(ecRunTestsDialog)
90     friend class ecResetThread;
91     friend class ecRunTestsTimer; 
92 public:
93     ecRunTestsDialog(wxWindow* parent);
94     ~ecRunTestsDialog();
95
96     void OnOK(wxCommandEvent& event);
97     void OnRun(wxCommandEvent& event);
98     void OnProperties(wxCommandEvent& event);
99     //void OnHelp(wxCommandEvent& event);
100     void OnPageChange(wxNotebookEvent& event);
101     void OnSize(wxSizeEvent& event);
102     void OnIdle(wxIdleEvent& event);
103     void OnCloseWindow(wxCloseEvent& event);
104
105     virtual bool TransferDataToWindow();
106     virtual bool TransferDataFromWindow();
107
108     inline wxNotebook* GetNotebook() const { return m_notebook; }
109
110     // Add the test to the dialog
111     void Populate(const wxString& test, bool select = TRUE);
112         void SubmitTests();
113
114     // Write to the output buffer for OnIdle to pick up
115     void OutputToBuffer(const wxString& str);
116     // Write any remaining text
117     void FlushBuffer();
118
119     // Thread callbacks
120     static void RunCallback(void *pParam);
121     static void CALLBACK RunLocalFunc(void *pParam);
122     static void CALLBACK RunRemoteFunc(void *pParam);
123         static void CALLBACK TestOutputCallback(void *pParam,LPCTSTR psz);
124
125     // Helpers
126     // Translate from Windows to Unix serial port nomenclature
127     wxString TranslatePort(const wxString& port) const;
128         
129 protected:
130
131     ecRunTestsExecutablesDialog*            m_executables;
132     ecRunTestsOutputDialog*                 m_output;
133     ecRunTestsSummaryDialog*                m_summary;
134     wxNotebook*                             m_notebook;
135
136     ecRunStatus                             m_runStatus;
137     CeCosTest::ExecutionParameters          m_ep;
138         int                                     m_nNextToSubmit;
139     CTestResource*                          m_pResource;
140     CProperties                             m_prop;
141     wxCriticalSection                       m_CS;
142     static ecRunTestsDialog*                m_runTestsDialog;
143     bool                                    m_testsAreComplete;
144
145     // Output text by writing to the buffer and letting
146     // OnIdle pick it up
147     wxString                                m_outputBuffer;
148     bool                                    m_outputBufferPresent;
149     ecRunTestsTimer                         m_timer;
150 DECLARE_EVENT_TABLE()
151 };
152
153 /* Executables dialog
154  */
155
156 class ecRunTestsExecutablesDialog: public wxPanel
157 {
158 DECLARE_CLASS(ecRunTestsExecutablesDialog)
159 DECLARE_EVENT_TABLE()
160 public:
161     ecRunTestsExecutablesDialog(wxWindow* parent);
162
163     void CreateControls( wxPanel *parent);
164     void AddFromFolder(const wxString& folder, bool recurse, const wxString& wildcard);
165     int SelectedTestCount();
166         wxString SelectedTest(int nIndex);
167
168     void OnCheckAll(wxCommandEvent& event);
169     void OnUncheckAll(wxCommandEvent& event);
170     void OnAdd(wxCommandEvent& event);
171     void OnAddFromFolder(wxCommandEvent& event);
172     void OnRemove(wxCommandEvent& event);
173     void OnUpdateCheckAll(wxUpdateUIEvent& event);
174     void OnUpdateUncheckAll(wxUpdateUIEvent& event);
175 };
176
177 #define ecID_RUN_TESTS_CHECK_ALL 10072
178 #define ecID_RUN_TESTS_UNCHECK_ALL 10073
179 #define ecID_RUN_TESTS_ADD 10074
180 #define ecID_RUN_TESTS_ADD_FOLDER 10075
181 #define ecID_RUN_TESTS_REMOVE 10076
182 #define ecID_RUN_TESTS_TEST_LIST 2063
183
184 /* Output dialog
185  */
186
187 class ecRunTestsOutputDialog: public wxPanel
188 {
189 DECLARE_CLASS(ecRunTestsOutputDialog)
190 public:
191     ecRunTestsOutputDialog(wxWindow* parent);
192
193     void CreateControls( wxPanel *parent);
194
195     void AddText(const wxString& msg);
196     void AddLogMsg(const wxString& msg);
197 };
198
199 #define ecID_RUN_TESTS_OUTPUT_TEXT 10088
200
201 /* Summary dialog
202  */
203
204 class WXDLLEXPORT wxListCtrl;
205
206 // Windows requires the sort function to be of type
207 // CALLBACK
208 #ifndef CALLBACK
209 #define CALLBACK
210 #endif
211
212 class ecRunTestsSummaryDialog: public wxPanel
213 {
214 DECLARE_CLASS(ecRunTestsSummaryDialog)
215 DECLARE_EVENT_TABLE()
216 public:
217     ecRunTestsSummaryDialog(wxWindow* parent);
218
219     void CreateControls( wxPanel *parent);
220         void AddResult (CeCosTest *pTest);
221     void OnColClick(wxListEvent& event);
222     static int CALLBACK SummarySortFunc(long data1, long data2, long col);
223
224     static wxListCtrl* m_listCtrl;
225 };
226
227 #define ecID_RUN_TESTS_SUMMARY_LIST     2063
228
229 // Information used in thread processing
230 struct ecRunTestsInfo {
231   ecRunTestsDialog* pSheet;
232   CeCosTest      *  pTest;
233 };
234
235 // Thread class used for resetting a remote target
236 class ecResetThread : public wxThread
237 {
238 public:
239     ecResetThread(ecRunTestsInfo* info) { m_info = info; };
240
241     // thread execution starts here
242     virtual void *Entry();
243
244     // called when the thread exits - whether it terminates normally or is
245     // stopped with Delete() (but not when it is Kill()ed!)
246     virtual void OnExit();
247
248 public:
249     ecRunTestsInfo* m_info;
250 };
251
252
253 #endif
254     // _ECOS_RUNTESTSDLG_H_