os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tsgdriver.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent - Graphics Resource API Conformance Test Suite
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include "tsgdriver.h"
sl@0
    23
sl@0
    24
CTSgDriver::CTSgDriver(TBool aConformanceTests) :
sl@0
    25
	CTSgTestStepBase(aConformanceTests)
sl@0
    26
	{
sl@0
    27
	INFO_PRINTF1(_L("Graphics resource component test - SgDriver Tests.\r\n"));
sl@0
    28
	}
sl@0
    29
sl@0
    30
CTSgDriver::~CTSgDriver()
sl@0
    31
	{
sl@0
    32
	}
sl@0
    33
sl@0
    34
/** 
sl@0
    35
Overrides of base class pure virtual
sl@0
    36
Our implementation only gets called if the base class doTestStepPreambleL() did
sl@0
    37
not leave. That being the case, the current test result value will be EPass.
sl@0
    38
@leave Gets system wide error code
sl@0
    39
@return TVerdict code
sl@0
    40
*/
sl@0
    41
TVerdict CTSgDriver::doTestStepL()
sl@0
    42
	{	
sl@0
    43
	SetTestStepID(_L("GRAPHICS-RESOURCE-0022"));
sl@0
    44
	INFO_PRINTF1(_L("Shutting down an uninitialised driver.\r\n"));
sl@0
    45
	TestShutdownUninitialized();
sl@0
    46
	RecordTestResultL();
sl@0
    47
sl@0
    48
	SetTestStepID(_L("GRAPHICS-RESOURCE-0096"));
sl@0
    49
	INFO_PRINTF1(_L("Checking the driver is the correct version.\r\n"));
sl@0
    50
	TestVersion();
sl@0
    51
	RecordTestResultL();
sl@0
    52
	
sl@0
    53
	SetTestStepID(_L("GRAPHICS-RESOURCE-0099"));
sl@0
    54
	INFO_PRINTF1(_L("Checking the driver returns the correct error on multiple opens.\r\n"));
sl@0
    55
	TestMultipleOpens();
sl@0
    56
	RecordTestResultL();
sl@0
    57
	
sl@0
    58
	SetTestStepID(_L("GRAPHICS-RESOURCE-0103"));
sl@0
    59
	INFO_PRINTF1(_L("Checking GetInterface() returns correct error codes.\r\n"));
sl@0
    60
	TestGetInterface();
sl@0
    61
	RecordTestResultL();
sl@0
    62
	
sl@0
    63
	return TestStepResult();
sl@0
    64
	}
sl@0
    65
sl@0
    66
/**
sl@0
    67
@SYMTestCaseID			GRAPHICS-RESOURCE-0022
sl@0
    68
@SYMTestCaseDesc		Shuts down an uninitialised driver.
sl@0
    69
@SYMPREQ				PREQ2637
sl@0
    70
@SYMFssID				RSgDriver::Close()
sl@0
    71
@SYMTestPriority		Low
sl@0
    72
@SYMTestType			UT
sl@0
    73
@SYMTestPurpose			To ensure invalid Close() calls on the driver will cause no errors.
sl@0
    74
@SYMTestActions			Call RSgDriver::Close() several times without calling RSgDriver::Open().
sl@0
    75
@SYMTestExpectedResults	No errors should be returned.
sl@0
    76
 */	
sl@0
    77
void CTSgDriver::TestShutdownUninitialized()
sl@0
    78
	{
sl@0
    79
	__UHEAP_MARK;	
sl@0
    80
	
sl@0
    81
	RSgDriver sgDriver;
sl@0
    82
	
sl@0
    83
	sgDriver.Close();
sl@0
    84
	sgDriver.Close();
sl@0
    85
	sgDriver.Close();
sl@0
    86
	
sl@0
    87
	__UHEAP_MARKEND;
sl@0
    88
	}
sl@0
    89
sl@0
    90
/**
sl@0
    91
@SYMTestCaseID			GRAPHICS-RESOURCE-0096
sl@0
    92
@SYMTestCaseDesc		Test the version number returned by RSgDriver is correct.
sl@0
    93
@SYMPREQ				PREQ2637
sl@0
    94
@SYMFssID				RSgDriver::Version()
sl@0
    95
@SYMTestPriority		Medium
sl@0
    96
@SYMTestType			UT
sl@0
    97
@SYMTestPurpose			To check the correct version of the driver is being used in the
sl@0
    98
						conformance tests.
sl@0
    99
@SYMTestActions			Call RSgDriver::Version().
sl@0
   100
@SYMTestExpectedResults	The correct version should be returned.
sl@0
   101
 */	
sl@0
   102
void CTSgDriver::TestVersion()
sl@0
   103
	{
sl@0
   104
	__UHEAP_MARK;	
sl@0
   105
	
sl@0
   106
	RSgDriver sgDriver;
sl@0
   107
	
sl@0
   108
	TVersion vers = sgDriver.Version();
sl@0
   109
	TEST(vers.iMajor == 1);
sl@0
   110
	TEST(vers.iMinor == 1);
sl@0
   111
	
sl@0
   112
	__UHEAP_MARKEND;
sl@0
   113
	}
sl@0
   114
sl@0
   115
/**
sl@0
   116
@SYMTestCaseID			GRAPHICS-RESOURCE-0099
sl@0
   117
@SYMTestCaseDesc		Test SgDriver Handles Multiple Calls to Open Correctly
sl@0
   118
@SYMPREQ				PREQ2637
sl@0
   119
@SYMFssID				RSgDriver::Open()
sl@0
   120
@SYMTestPriority		High
sl@0
   121
@SYMTestType			UT
sl@0
   122
@SYMTestPurpose			To ensure the correct error code is returned when an open
sl@0
   123
						driver is opened
sl@0
   124
@SYMTestActions			Call RSgDriver::Open().
sl@0
   125
@SYMTestExpectedResults	KErrInUse should be returned when the driver is opened for
sl@0
   126
						the second time and all subsequent times.
sl@0
   127
 */	
sl@0
   128
void CTSgDriver::TestMultipleOpens()
sl@0
   129
	{
sl@0
   130
	__UHEAP_MARK;	
sl@0
   131
	
sl@0
   132
	TInt err = KErrNone;
sl@0
   133
	RSgDriver sgDriver;
sl@0
   134
	
sl@0
   135
	err = sgDriver.Open();
sl@0
   136
	TESTE(KErrNone == err, err);
sl@0
   137
	err = sgDriver.Open();
sl@0
   138
	TESTE(KErrInUse == err, err);
sl@0
   139
	err = sgDriver.Open();
sl@0
   140
	TESTE(KErrInUse == err, err);
sl@0
   141
	err = sgDriver.Open();
sl@0
   142
	TESTE(KErrInUse == err, err);	
sl@0
   143
	sgDriver.Close();	
sl@0
   144
	
sl@0
   145
	__UHEAP_MARKEND;
sl@0
   146
	}
sl@0
   147
sl@0
   148
/**
sl@0
   149
@SYMTestCaseID			GRAPHICS-RESOURCE-0103
sl@0
   150
@SYMTestCaseDesc		Test that GetInterface() returns the correct error code	in 
sl@0
   151
						negative situations.
sl@0
   152
@SYMPREQ				PREQ2637
sl@0
   153
@SYMFssID				RSgDriver::GetInterface()
sl@0
   154
@SYMTestPriority		Low
sl@0
   155
@SYMTestType			UT
sl@0
   156
@SYMTestPurpose			To ensure the correct error code is returned when GetInterface() 
sl@0
   157
						is used, in a variety of sitations.
sl@0
   158
@SYMTestActions			Call RSgDriver::GetInterface() with an interface that is valid but
sl@0
   159
						not supported by the driver.			
sl@0
   160
						Call RSgDriver::GetInterface() with an interface with a Null ID.
sl@0
   161
						Call RSgDriver::GetInterface() with any interface, on a driver that
sl@0
   162
						is not yet open.
sl@0
   163
@SYMTestExpectedResults	When using an unsupported interface, KErrExtensionNotSupported should 
sl@0
   164
						be returned.
sl@0
   165
						When using an interface with the null UID, KErrArgument should be returned.
sl@0
   166
						When using any interface after the driver is closed, KErrBadHandle
sl@0
   167
						should be returned.
sl@0
   168
 */
sl@0
   169
sl@0
   170
/**
sl@0
   171
Test classes for testing with RSgImage::GetInterface()
sl@0
   172
 */
sl@0
   173
class MFakeInterface
sl@0
   174
    {
sl@0
   175
public:
sl@0
   176
    enum { EInterfaceUid = 0x88888888 };
sl@0
   177
    };
sl@0
   178
class MNullInterface
sl@0
   179
    {
sl@0
   180
public:
sl@0
   181
    enum { EInterfaceUid = KNullUidValue };
sl@0
   182
    };
sl@0
   183
sl@0
   184
void CTSgDriver::TestGetInterface()
sl@0
   185
	{
sl@0
   186
	__UHEAP_MARK;
sl@0
   187
	
sl@0
   188
	RSgDriver sgDriver;
sl@0
   189
	TInt err = sgDriver.Open();
sl@0
   190
	TESTE(err == KErrNone, err);
sl@0
   191
	
sl@0
   192
	MFakeInterface* fakeInterface = NULL;
sl@0
   193
	err = sgDriver.GetInterface(fakeInterface);
sl@0
   194
	TESTE(err == KErrExtensionNotSupported, err);	
sl@0
   195
	
sl@0
   196
	MNullInterface* nullInterface = NULL;
sl@0
   197
	err = sgDriver.GetInterface(nullInterface);
sl@0
   198
	TESTE(err == KErrArgument, err);
sl@0
   199
	
sl@0
   200
	sgDriver.Close();	
sl@0
   201
	err = sgDriver.GetInterface(fakeInterface);
sl@0
   202
	TESTE(err == KErrBadHandle, err);
sl@0
   203
	err = sgDriver.GetInterface(nullInterface);
sl@0
   204
	TESTE(err == KErrBadHandle, err);
sl@0
   205
	
sl@0
   206
	__UHEAP_MARKEND;
sl@0
   207
	}