⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 symbianosunitappui.cpp

📁 symbian 3rd下的单元测试工具 里面包括一个框架 一个实例程序 还有使用手册 很好用的 我自己用过 有问题的可以交流奥
💻 CPP
字号:
// CSymbianOSUnitAppUi.cpp
// -----------------
//
// Copyright (c) 2003-2006 Penrillian Ltd.  All rights reserved.
//Web: www.penrillian.com


#include "SymbianOSUnit.h"
#include "Logger.h"
#include "TestDriver.h"
#include <w32std.h> // RWsSession 

_LIT(KTestLogsDir, "SymbianOSUnit");
const TInt KMaxCmds = 2000;

void CSymbianOSUnitAppUi::ConstructL()
{
#ifdef UIQ3
	CQikAppUi::ConstructL();
	AddViewL(*CSymbianOSUnitAppView::NewLC(*this));
	CleanupStack::Pop(); // view
#else
    BaseConstructL();
	iAppView = CSymbianOSUnitAppView::NewL(ClientRect());
#endif

	Logger::StartL(KTestLogsDir);
	
	// need this to support series60 scrollbar
#if defined SERIES60 || defined SERIES60_3RD
	iAppView->SetMopParent(this);

#elif defined UIQ
	CDesCArrayFlat* suiteNames = new (ELeave) CDesCArrayFlat(3);
	CleanupStack::PushL(suiteNames);
	TestDriver::TestSuiteNamesL(*suiteNames);
	if(suiteNames->MdcaCount() == 0)
	{
		CEikButtonGroupContainer* toolBar = iEikonEnv->AppUiFactory()->ToolBar();
		toolBar->DimCommand(ECmdRunTest, ETrue);
	}
	CleanupStack::PopAndDestroy(suiteNames);
#endif
	iEikonEnv->WsSession().SetAutoFlush(ETrue);
}

#ifdef UIQ3
CDesCArray* CSymbianOSUnitAppUi::SuiteNamesLC()
{
	CDesCArrayFlat* suiteNames = new (ELeave) CDesCArrayFlat(3);
	CleanupStack::PushL(suiteNames);
	TestDriver::TestSuiteNamesL(*suiteNames);
	return suiteNames;
}

#endif


CSymbianOSUnitAppUi::~CSymbianOSUnitAppUi()
{
	Logger::Finish();
#ifndef UIQ3
	delete iAppView;
	iAppView = NULL;
#endif
}


#ifndef UIQ3

void CSymbianOSUnitAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
	if(aResourceId == R_FILE_FIRST_MENU)
	{
		CDesCArrayFlat* suiteNames = new (ELeave) CDesCArrayFlat(3);
		CleanupStack::PushL(suiteNames);
		TestDriver::TestSuiteNamesL(*suiteNames);
		if(suiteNames->MdcaCount() == 0)
		{
			aMenuPane->SetItemDimmed(ECmdRunTest, ETrue);
		}
		else
		{
			CEikMenuPaneItem::SData data;
			data.iCascadeId = 0; 
			data.iFlags = 0; 
			for(TInt i = 0; i < suiteNames->MdcaCount(); i++)
			{
				data.iCommandId = ECmdRunTest + i +1;
				data.iText = suiteNames->MdcaPoint(i);
#if defined SERIES60 || defined SERIES60_3RD
				aMenuPane->InsertMenuItemL(data, i+1);
#elif defined UIQ || defined SERIES80
				aMenuPane->InsertMenuItemAtL(data, i+1);
#endif
			}
		}
		CleanupStack::PopAndDestroy(suiteNames);
	}

}

void CSymbianOSUnitAppUi::HandleCommandL(TInt aCommand)
{	
	switch (aCommand)
	{					
		case EEikCmdExit: 
		{
			Exit();
			break;
		}
		case ECmdRunTest:
		{
			RunTests();
			break;
		}
		default:
		{
			RunTests(aCommand - ECmdRunTest -1);
			break;
		}
	}
}

void CSymbianOSUnitAppUi::RunTests(TInt aSuite)
{
	TRAPD(err, iAppView->ClearViewL() );
	TRAP(err,iAppView->RunSuitesL(aSuite));		
	if(err != KErrNone)
	{
		User::InfoPrint(_L("Leave: could not run tests"));
	}
}

#if defined SERIES60_3RD
void CSymbianOSUnitAppUi::HandleStatusPaneSizeChange()
{
	iAppView->SetRect( ClientRect() );
}
#endif

#endif //not UIQ3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -