1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
22 #include <featurenotifier.h> |
22 #include <featurenotifier.h> |
23 #include "../../../src/clientdll/featmgrresourcetester.h" |
23 #include "../../../src/clientdll/featmgrresourcetester.h" |
24 |
24 |
25 using namespace NFeature; |
25 using namespace NFeature; |
26 |
26 |
27 _LIT( KZOrgFeaturesFile, "Z:\\Private\\10205054\\features.dat" ); |
|
28 #ifdef EXTENDED_FEATURE_MANAGER_TEST |
|
29 _LIT( KZFeaturesFile, "C:\\Private\\102836E5\\features.dat" ); |
|
30 _LIT( KZFeaturesDir, "C:\\Private\\102836E5\\" ); |
|
31 #else |
|
32 _LIT( KZFeaturesFile, "Z:\\Private\\10205054\\features.dat" ); |
|
33 _LIT( KZFeaturesDir, "Z:\\Private\\10205054\\" ); |
|
34 #endif // EXTENDED_FEATURE_MANAGER_TEST |
|
35 |
27 |
36 const TInt KInvalidFeatureId = 90901671; |
28 const TInt KInvalidFeatureId = 90901671; |
37 const TUid KInvalidFeatureUid = {KInvalidFeatureId}; |
29 const TUid KInvalidFeatureUid = {KInvalidFeatureId}; |
38 |
30 |
39 static TInt TheProcessHandleCount = 0; |
31 static TInt TheProcessHandleCount = 0; |
40 static TInt TheThreadHandleCount = 0; |
32 static TInt TheThreadHandleCount = 0; |
41 static TInt TheAllocatedCellsCount = 0; |
33 static TInt TheAllocatedCellsCount = 0; |
|
34 |
|
35 #ifdef _DEBUG |
42 static const TInt KBurstRate = 20; |
36 static const TInt KBurstRate = 20; |
43 |
37 #endif |
44 |
38 |
45 enum TFeatMgrOomTestMode |
39 enum TFeatMgrOomTestMode |
46 { |
40 { |
47 EFeatMgrOomServerTestMode, |
41 EFeatMgrOomServerTestMode, |
48 EFeatMgrOomClientTestMode, |
42 EFeatMgrOomClientTestMode, |
50 |
44 |
51 /////////////////////////////////////////////////////////////////////////////////////// |
45 /////////////////////////////////////////////////////////////////////////////////////// |
52 |
46 |
53 static RTest TheTest(_L("t_fmgroom")); |
47 static RTest TheTest(_L("t_fmgroom")); |
54 |
48 |
55 /////////////////////////////////////////////////////////////////////////////////////// |
49 |
56 |
|
57 //Deletes all created test files. |
|
58 void DestroyTestEnv() |
|
59 { |
|
60 } |
|
61 |
50 |
62 /////////////////////////////////////////////////////////////////////////////////////// |
51 /////////////////////////////////////////////////////////////////////////////////////// |
63 /////////////////////////////////////////////////////////////////////////////////////// |
52 /////////////////////////////////////////////////////////////////////////////////////// |
64 //Test macros and functions |
53 //Test macros and functions |
65 void Check1(TInt aValue, TInt aLine) |
54 void Check1(TInt aValue, TInt aLine) |
66 { |
55 { |
67 if(!aValue) |
56 if(!aValue) |
68 { |
57 { |
69 DestroyTestEnv(); |
|
70 RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine); |
58 RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine); |
71 TheTest(EFalse, aLine); |
59 TheTest(EFalse, aLine); |
72 } |
60 } |
73 } |
61 } |
74 void Check2(TInt aValue, TInt aExpected, TInt aLine) |
62 void Check2(TInt aValue, TInt aExpected, TInt aLine) |
75 { |
63 { |
76 if(aValue != aExpected) |
64 if(aValue != aExpected) |
77 { |
65 { |
78 DestroyTestEnv(); |
|
79 RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine); |
66 RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine); |
80 TheTest(EFalse, aLine); |
67 TheTest(EFalse, aLine); |
81 } |
68 } |
82 } |
69 } |
83 #define TEST(arg) ::Check1((arg), __LINE__) |
70 #define TEST(arg) ::Check1((arg), __LINE__) |
312 TEST2(err, KErrNone); |
299 TEST2(err, KErrNone); |
313 |
300 |
314 const TUid KNewFeatureUid = {0x7888ABCE}; |
301 const TUid KNewFeatureUid = {0x7888ABCE}; |
315 TBitFlags32 flags; |
302 TBitFlags32 flags; |
316 flags.Set(EFeatureSupported); |
303 flags.Set(EFeatureSupported); |
317 flags.Set(EFeatureModifiable); |
304 flags.Set(EFeatureModifiable); |
|
305 flags.Set(EFeaturePersisted); |
318 TFeatureEntry fentry(KNewFeatureUid, flags, 0x0); |
306 TFeatureEntry fentry(KNewFeatureUid, flags, 0x0); |
319 |
307 |
320 err = KErrNoMemory; |
308 err = KErrNoMemory; |
321 TInt failingAllocationNo = 0; |
309 TInt failingAllocationNo = 0; |
322 TheTest.Printf(_L("Iteration:\r\n")); |
310 TheTest.Printf(_L("Iteration:\r\n")); |
527 ctrl.Close(); |
515 ctrl.Close(); |
528 delete scheduler; |
516 delete scheduler; |
529 TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo); |
517 TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo); |
530 } |
518 } |
531 |
519 |
532 void PreTest() |
520 |
533 { |
|
534 // Connect session |
|
535 RFs fsSession; |
|
536 User::LeaveIfError(fsSession.Connect()); |
|
537 |
|
538 TEntry entry; |
|
539 TInt err = fsSession.Entry(KZFeaturesDir, entry); |
|
540 if (err == KErrNotFound) |
|
541 { |
|
542 err = fsSession.MkDir(KZFeaturesDir); |
|
543 } |
|
544 TEST2 (err, KErrNone); |
|
545 err = BaflUtils::CopyFile(fsSession, KZOrgFeaturesFile, KZFeaturesDir); |
|
546 TEST2 (err, KErrNone); |
|
547 |
|
548 // close file server session |
|
549 fsSession.Close(); |
|
550 |
|
551 } |
|
552 |
|
553 void PostTest() |
|
554 { |
|
555 // Connect session |
|
556 RFs fsSession; |
|
557 User::LeaveIfError(fsSession.Connect()); |
|
558 |
|
559 TEntry entry; |
|
560 TInt err = fsSession.Entry(KZFeaturesDir, entry); |
|
561 TEST2 (err, KErrNone); |
|
562 if (err == KErrNone) |
|
563 { |
|
564 //if not extended this is attempting to delte from the Z drive |
|
565 #ifdef EXTENDED_FEATURE_MANAGER_TEST |
|
566 err = BaflUtils::DeleteFile(fsSession,KZFeaturesFile); |
|
567 TEST2 (err, KErrNone); |
|
568 #endif |
|
569 } |
|
570 // close file server session |
|
571 fsSession.Close(); |
|
572 } |
|
573 |
521 |
574 void DoTestsL() |
522 void DoTestsL() |
575 { |
523 { |
576 |
|
577 TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4068 RFeatureControl::Connect() OOM test")); |
524 TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4068 RFeatureControl::Connect() OOM test")); |
578 PreTest(); |
|
579 ControlOpenOomTest(ETrue); |
525 ControlOpenOomTest(ETrue); |
580 TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4069 RFeatureControl::Open() OOM test")); |
526 TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4069 RFeatureControl::Open() OOM test")); |
581 ControlOpenOomTest(EFalse); |
527 ControlOpenOomTest(EFalse); |
582 |
528 |
583 TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4070 RFeatureControl::FeatureSupported(UID) + valid feature, client side OOM test")); |
529 TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4070 RFeatureControl::FeatureSupported(UID) + valid feature, client side OOM test")); |
637 |
583 |
638 TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4092 CFeatureNotifier::NotifyRequest(<array>), valid feature, client side OOM test")); |
584 TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4092 CFeatureNotifier::NotifyRequest(<array>), valid feature, client side OOM test")); |
639 NotifierNotifyRequestsOomTest(EFeatMgrOomClientTestMode); |
585 NotifierNotifyRequestsOomTest(EFeatMgrOomClientTestMode); |
640 TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4093 CFeatureNotifier::NotifyRequest(<array>), valid feature, server side OOM test")); |
586 TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4093 CFeatureNotifier::NotifyRequest(<array>), valid feature, server side OOM test")); |
641 NotifierNotifyRequestsOomTest(EFeatMgrOomServerTestMode); |
587 NotifierNotifyRequestsOomTest(EFeatMgrOomServerTestMode); |
642 |
|
643 PostTest(); |
|
644 } |
588 } |
645 |
589 |
646 TInt E32Main() |
590 TInt E32Main() |
647 { |
591 { |
648 TheTest.Title(); |
592 TheTest.Title(); |