// TestRunnerDlg.cpp : implementation file
//

#include "stdafx.h"
#include "resource.h"
#include "act.h"
#include "actTestRunnerMfc.h"
#include "TestRunnerDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/* Notes:
 - code duplication between OnOK() and OnQuitApplication()
 - the threading need to be rewrite, so that GUI update occures in the original
 thread, not in the thread that is running the tests. This slow down the time
 needed to run the test much...
 */


/////////////////////////////////////////////////////////////////////////////
// TestRunnerDlg dialog


TestRunnerDlg::TestRunnerDlg(TestRunnerModel * model,
                             CWnd* pParent /*=NULL*/)
	: cdxCDynamicDialog(TestRunnerDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(TestRunnerDlg)
	m_bAutorunAtStartup = FALSE;
	//}}AFX_DATA_INIT
    init(model);
}

void 
TestRunnerDlg::init(TestRunnerModel *model)
{

}

void 
TestRunnerDlg::DoDataExchange(CDataExchange* pDX)
{
  cdxCDynamicDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(TestRunnerDlg)
	DDX_Control(pDX, IDC_DETAILS, m_details);
	DDX_Control(pDX, IDC_LIST, m_listCtrl);
	DDX_Control(pDX, IDOK, m_buttonClose);
	DDX_Control(pDX, ID_STOP, m_buttonStop);
	DDX_Control(pDX, ID_RUN, m_buttonRun);
	DDX_Control(pDX, IDC_BROWSE_TEST, m_buttonBrowse);
	DDX_Check(pDX, IDC_CHECK_AUTORUN, m_bAutorunAtStartup);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(TestRunnerDlg, cdxCDynamicDialog)
	//{{AFX_MSG_MAP(TestRunnerDlg)
	ON_BN_CLICKED(ID_RUN, OnRun)
	ON_BN_CLICKED(ID_STOP, OnStop)
	ON_BN_CLICKED(IDC_BROWSE_TEST, OnBrowseTest)
	ON_COMMAND(ID_QUIT_APPLICATION, OnQuitApplication)
	ON_WM_CLOSE()
	ON_WM_SIZE()
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST, OnSelectedFailureChange)
	ON_CBN_SELCHANGE(IDC_COMBO_TEST, OnSelectTestInHistoryCombo)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// TestRunnerDlg message handlers

BOOL 
TestRunnerDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


TestRunnerDlg::~TestRunnerDlg()
{

}


void 
TestRunnerDlg::OnRun() 
{
	// TODO: Add your control notification handler code here
	
}

void 
TestRunnerDlg::addListEntry()
{

}

void TestRunnerDlg::startTest(ITestListener *self, ITest *test)
{

}

void TestRunnerDlg::addFailure(ITestListener *self, ITest *test, char *msg, int line, char *file)
{

}

void 
TestRunnerDlg::endTest(ITestListener *self, ITest *test)
{

}

void 
TestRunnerDlg::beRunning()
{

}

void 
TestRunnerDlg::beIdle()
{

}

void TestRunnerDlg::beRunDisabled()
{

}

void TestRunnerDlg::freeState()
{

}

void TestRunnerDlg::reset()
{

}

void TestRunnerDlg::updateCountsDisplay()
{

}

void TestRunnerDlg::OnStop() 
{
	// TODO: Add your control notification handler code here
	
}

void 
TestRunnerDlg::OnOK() 
{
  cdxCDynamicDialog::OnOK ();
}


void TestRunnerDlg::OnSelectTestInHistoryCombo() 
{
	// TODO: Add your control notification handler code here
	
}

void TestRunnerDlg::updateHistoryCombo()
{

}

void 
TestRunnerDlg::OnBrowseTest() 
{
	// TODO: Add your control notification handler code here
	
}

BOOL TestRunnerDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return cdxCDynamicDialog::PreTranslateMessage(pMsg);
}

CComboBox * 
TestRunnerDlg::getHistoryCombo()
{
  CComboBox   *comboBox = (CComboBox *)GetDlgItem (IDC_COMBO_TEST);
  ASSERT (comboBox);
  return comboBox;
}

void TestRunnerDlg::loadSettings()
{

}

void TestRunnerDlg::saveSettings()
{

}

void 
TestRunnerDlg::OnQuitApplication() 
{
	// TODO: Add your command handler code here
	
}

TestRunnerModel & 
TestRunnerDlg::model()
{
  ASSERT( m_model != NULL );
  return *m_model;
}

void TestRunnerDlg::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	
	cdxCDynamicDialog::OnClose();
}

CRect 
TestRunnerDlg::getItemWindowRect(unsigned int itemId)
{
  CWnd * pItem = GetDlgItem( itemId );
  CRect rect;
  if ( pItem )
    pItem->GetWindowRect( &rect );
  return rect;
}


CRect 
TestRunnerDlg::getItemClientRect(unsigned int itemId)
{
  CRect rect = getItemWindowRect( itemId );
  if ( !rect.IsRectNull() )
  {
    CPoint clientTopLeft = rect.TopLeft();
    ScreenToClient( &clientTopLeft );
    rect = CRect( clientTopLeft, rect.Size() );
  }

  return rect;
}

void TestRunnerDlg::initializeLayout()
{

}

void TestRunnerDlg::OnSize(UINT nType, int cx, int cy) 
{
	cdxCDynamicDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	
}

void TestRunnerDlg::updateListColumnSize()
{

}

void TestRunnerDlg::OnSelectedFailureChange(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void TestRunnerDlg::displayFailureDetailsFor(unsigned int failureIndex)
{

}

void TestRunnerDlg::initializeFixedSizeFont()
{

}
