72
|
1 |
//
|
|
2 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
// All rights reserved.
|
|
4 |
// This component and the accompanying materials are made available
|
|
5 |
// under the terms of "Eclipse Public License v1.0"
|
|
6 |
// which accompanies this distribution, and is available
|
|
7 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
//
|
|
9 |
// Initial Contributors:
|
|
10 |
// Nokia Corporation - initial contribution.
|
|
11 |
//
|
|
12 |
// Contributors:
|
|
13 |
//
|
|
14 |
// Description:
|
|
15 |
//
|
|
16 |
//
|
|
17 |
//
|
|
18 |
// This contains CommDb Unit Test Cases 0064.XX
|
|
19 |
|
|
20 |
// EPOC includes
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <commdb.h>
|
|
23 |
|
|
24 |
|
|
25 |
// Test system includes
|
|
26 |
//#include <networking/log.h>
|
|
27 |
//#include <networking/teststep.h>
|
|
28 |
#include "Teststepcommdb.h"
|
|
29 |
#include "Step_064_xx.h"
|
|
30 |
|
|
31 |
#include <commsdattypeinfov1_1.h>
|
|
32 |
#include <commsdattypesv1_1.h>
|
|
33 |
#include <commsdat_partner.h>
|
|
34 |
|
|
35 |
|
|
36 |
// table name
|
|
37 |
_LIT(KCDTypeNameTestTable, "Test");
|
|
38 |
|
|
39 |
#define KCDTypeNameBinaryFieldTest _S("BinaryTest")
|
|
40 |
|
|
41 |
// record type id
|
|
42 |
const TMDBElementId KCDTIdTestRecord = 0x5F800000;
|
|
43 |
// field type ids
|
|
44 |
const TMDBElementId KCDTIdTestBinaryField = 0x00150000;
|
|
45 |
|
|
46 |
|
|
47 |
static const SGenericRecordTypeInfo TestGenRecordInfoBinary[] =
|
|
48 |
{
|
|
49 |
MDB_GENERIC_TYPE_INFO(KCDTIdRecordTag, EUint32, ENoAttrs, KCDTypeNameRecordTag),
|
|
50 |
MDB_GENERIC_TYPE_INFO(KCDTIdRecordName, EText, ENotNull, KCDTypeNameRecordName),
|
|
51 |
MDB_GENERIC_TYPE_INFO(KCDTIdTestBinaryField, EDesC8, ENoAttrs, KCDTypeNameBinaryFieldTest),
|
|
52 |
MDB_GENERIC_TYPE_INFO(0, 0, ENoAttrs, KCDNull)
|
|
53 |
};
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
NONSHARABLE_CLASS(CCDTestBinaryRecord) : public CCDRecordBase
|
|
58 |
{
|
|
59 |
public :
|
|
60 |
|
|
61 |
// Constructor
|
|
62 |
CCDTestBinaryRecord(TMDBElementId aElementId)
|
|
63 |
: CCDRecordBase(aElementId),
|
|
64 |
iBinaryField((aElementId & KCDMaskShowRecordType) | KCDTIdTestBinaryField),
|
|
65 |
iRecordTag((aElementId & KCDMaskShowRecordType) | KCDTIdRecordTag),
|
|
66 |
iRecordName((aElementId & KCDMaskShowRecordType) | KCDTIdRecordName)
|
|
67 |
{}
|
|
68 |
|
|
69 |
const SRecordTypeInfo* GetRecordInfo(){return iRecordInfo;}
|
|
70 |
|
|
71 |
DATA_VTABLE
|
|
72 |
|
|
73 |
public :
|
|
74 |
|
|
75 |
CMDBField<TDesC8> iBinaryField;
|
|
76 |
CMDBField<TInt> iRecordTag;
|
|
77 |
CMDBField<TDesC> iRecordName;
|
|
78 |
|
|
79 |
private:
|
|
80 |
|
|
81 |
static const SRecordTypeInfo iRecordInfo[];
|
|
82 |
};
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
const SRecordTypeInfo CCDTestBinaryRecord::iRecordInfo[]=
|
|
88 |
{
|
|
89 |
{ KCDTIdRecordTag, EInt, ENoAttrs, KCDTypeNameRecordTag },
|
|
90 |
{ KCDTIdRecordName, EText, ENotNull, KCDTypeNameRecordName },
|
|
91 |
{ KCDTIdTestBinaryField, EDesC8, ENotNull, KCDTypeNameBinaryFieldTest },
|
|
92 |
{ 0, 0, ENoAttrs, KCDNull }
|
|
93 |
};
|
|
94 |
|
|
95 |
|
|
96 |
START_ATTRIBUTE_TABLE(CCDTestBinaryRecord, KCDTIdTestRecord, KCDTIdTestRecord )
|
|
97 |
X_REGISTER_ATTRIBUTE(CCDTestBinaryRecord, iBinaryField, TMDBBin)
|
|
98 |
X_REGISTER_ATTRIBUTE(CCDTestBinaryRecord, iRecordTag, TMDBNum )
|
|
99 |
X_REGISTER_ATTRIBUTE(CCDTestBinaryRecord, iRecordName, TMDBText )
|
|
100 |
END_ATTRIBUTE_TABLE()
|
|
101 |
|
|
102 |
|
|
103 |
_LIT8(KTestBinary, "a long binary string,a long binary string,a long binary string,a long binary string,a long binary string,a long binary string,a long binary string,end");
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
/////////////////////
|
|
110 |
// Test step 064.001
|
|
111 |
/////////////////////
|
|
112 |
|
|
113 |
// constructor
|
|
114 |
CCommDbTest064_01::CCommDbTest064_01()
|
|
115 |
{
|
|
116 |
// store the name of this test case
|
|
117 |
SetTestStepName(_L("step_064_01"));
|
|
118 |
}
|
|
119 |
|
|
120 |
// destructor
|
|
121 |
CCommDbTest064_01::~CCommDbTest064_01()
|
|
122 |
{
|
|
123 |
}
|
|
124 |
|
|
125 |
|
|
126 |
TInt CCommDbTest064_01::executeStepL()
|
|
127 |
{
|
|
128 |
TInt ret=KErrGeneral;
|
|
129 |
|
|
130 |
//set up a generic record with a binary field
|
|
131 |
INFO_PRINTF1(_L("Creating a user defined table"));
|
|
132 |
|
|
133 |
CMDBSession *cmdbSession = CMDBSession::NewL(KCDVersion1_1);
|
|
134 |
|
|
135 |
CleanupStack::PushL(cmdbSession);
|
|
136 |
|
|
137 |
CMDBGenericRecord* testRecord = static_cast<CMDBGenericRecord*>(CCDRecordBase::RecordFactoryL(KCDNewTableRequest));
|
|
138 |
CleanupStack::PushL(testRecord);
|
|
139 |
testRecord->InitializeL(KCDTypeNameTestTable(), TestGenRecordInfoBinary);
|
|
140 |
|
|
141 |
testRecord->StoreL(*cmdbSession);
|
|
142 |
CleanupStack::PopAndDestroy(testRecord);
|
|
143 |
CleanupStack::PopAndDestroy(cmdbSession);
|
|
144 |
|
|
145 |
|
|
146 |
//now use commdbshim api to read and write to the binary field
|
|
147 |
CCommsDatabase* theDb;
|
|
148 |
CCommsDbTableView* theView;
|
|
149 |
TUint32 recordId;
|
|
150 |
|
|
151 |
//CDBLEAVE( iTheView->PutRecordChanges(), KErrNone );
|
|
152 |
theDb = CCommsDatabase::NewL();
|
|
153 |
theView = theDb->OpenTableLC( KCDTypeNameTestTable );
|
|
154 |
CleanupStack::Pop();
|
|
155 |
|
|
156 |
TBuf8<KMaxLongTextLength> value(KTestBinary);
|
|
157 |
CDBLEAVE(theView->InsertRecord(recordId), KErrNone );
|
|
158 |
theView->WriteTextL(TPtrC(KCDTypeNameBinaryFieldTest), value );
|
|
159 |
CDBLEAVE(theView->PutRecordChanges(), KErrNone );
|
|
160 |
CDBLEAVE(theView->GotoFirstRecord(), KErrNone );
|
|
161 |
|
|
162 |
TBuf8<KMaxLongTextLength> value2;
|
|
163 |
theView->ReadTextL( TPtrC(KCDTypeNameBinaryFieldTest), value2 );
|
|
164 |
|
|
165 |
if( value2.Compare( value ) == 0)
|
|
166 |
{
|
|
167 |
ret = KErrNone;
|
|
168 |
}
|
|
169 |
|
|
170 |
delete theView;
|
|
171 |
delete theDb;
|
|
172 |
|
|
173 |
return ret;
|
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
TVerdict CCommDbTest064_01::doTestStepL( )
|
|
178 |
{
|
|
179 |
SetTestStepResult(EFail);
|
|
180 |
|
|
181 |
INFO_PRINTF1(_L("Step 064.01 called "));
|
|
182 |
if ( executeStepL() == KErrNone )
|
|
183 |
{
|
|
184 |
SetTestStepResult(EPass);
|
|
185 |
}
|
|
186 |
|
|
187 |
return TestStepResult();
|
|
188 |
}
|
|
189 |
|
|
190 |
|