sl@0
|
1 |
// Copyright (c) 2002-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 the License "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 |
// e32test\pipe\t_pipe2.cpp
|
sl@0
|
15 |
// This is supporting program for testing pipes.
|
sl@0
|
16 |
// This is used by main test file ( t_pipe.cpp) for testing
|
sl@0
|
17 |
// pipes in multiprocess environment.
|
sl@0
|
18 |
//
|
sl@0
|
19 |
//
|
sl@0
|
20 |
|
sl@0
|
21 |
#define __E32TEST_EXTENSION__
|
sl@0
|
22 |
#include <e32test.h>
|
sl@0
|
23 |
#include <e32svr.h>
|
sl@0
|
24 |
#include <rpipe.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
LOCAL_D RTest test(_L("t_pipe2"));
|
sl@0
|
28 |
_LIT(KPipeName5, "InterProcessPipe1");
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
_LIT8(KTestDataIP, "ABCDEFGHIJ");
|
sl@0
|
32 |
_LIT8(KTestData,"Pipe Data To Be Passed");
|
sl@0
|
33 |
|
sl@0
|
34 |
LOCAL_C void RunTests(void)
|
sl@0
|
35 |
{
|
sl@0
|
36 |
test.Start(_L("Testing In Pipe Process 2"));
|
sl@0
|
37 |
|
sl@0
|
38 |
TInt ret; // Return value variable
|
sl@0
|
39 |
|
sl@0
|
40 |
RPipe aReader;
|
sl@0
|
41 |
RPipe aReaderUN;
|
sl@0
|
42 |
const TBufC<50> cPipeName1(KPipeName5);
|
sl@0
|
43 |
|
sl@0
|
44 |
TBuf8<150> cPipeReadData1;
|
sl@0
|
45 |
TInt aSize;
|
sl@0
|
46 |
TRequestStatus stat1;
|
sl@0
|
47 |
|
sl@0
|
48 |
test.Next(_L("PIPE TEST: PipeProcess 2-1: Open Read Handle to unamed Pipe\n"));
|
sl@0
|
49 |
ret=aReaderUN.Open(3,EOwnerProcess);
|
sl@0
|
50 |
test_KErrNone(ret);
|
sl@0
|
51 |
|
sl@0
|
52 |
test.Next(_L("PIPE TEST: PipeProcess 2-1.1: Get the UnNamed pipe read handle from another process \n"));
|
sl@0
|
53 |
ret = aReaderUN.Size();
|
sl@0
|
54 |
test (ret = 22);
|
sl@0
|
55 |
|
sl@0
|
56 |
ret = aReaderUN.MaxSize();
|
sl@0
|
57 |
test (ret = 512);
|
sl@0
|
58 |
|
sl@0
|
59 |
ret = aReaderUN.Read(cPipeReadData1,22);
|
sl@0
|
60 |
test (ret == 22);
|
sl@0
|
61 |
|
sl@0
|
62 |
ret = cPipeReadData1.Compare(KTestData);
|
sl@0
|
63 |
test (ret == KErrNone);
|
sl@0
|
64 |
|
sl@0
|
65 |
aReaderUN.Close();
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
test.Next(_L("Open handle to named pipe\n"));
|
sl@0
|
69 |
|
sl@0
|
70 |
aSize =10;
|
sl@0
|
71 |
ret = aReader.Open(cPipeName1, RPipe::EOpenToRead);
|
sl@0
|
72 |
test_KErrNone(ret);
|
sl@0
|
73 |
|
sl@0
|
74 |
test.Next(_L("PIPE TEST: PipeProcess 2-2: Wait till NotifyDataAvailable.\n"));
|
sl@0
|
75 |
|
sl@0
|
76 |
aReader.NotifyDataAvailable(stat1);
|
sl@0
|
77 |
|
sl@0
|
78 |
User::WaitForRequest(stat1);
|
sl@0
|
79 |
|
sl@0
|
80 |
test.Next(_L("PIPE TEST: PipeProcess 2-3: Call ReadBlocking and Read the data.\n"));
|
sl@0
|
81 |
|
sl@0
|
82 |
aReader.Flush();
|
sl@0
|
83 |
ret = aReader.ReadBlocking(cPipeReadData1,aSize);
|
sl@0
|
84 |
test_Equal(aSize, ret);
|
sl@0
|
85 |
ret = cPipeReadData1.Compare(KTestDataIP);
|
sl@0
|
86 |
test( ret== KErrNone);
|
sl@0
|
87 |
|
sl@0
|
88 |
test.Next(_L("PIPE TEST: PipeProcess 2-4: Exit Process t_pipe2.\n"));
|
sl@0
|
89 |
aReader.Close();
|
sl@0
|
90 |
test.End();
|
sl@0
|
91 |
test.Close();
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
GLDEF_C TInt E32Main()
|
sl@0
|
95 |
//
|
sl@0
|
96 |
//
|
sl@0
|
97 |
{
|
sl@0
|
98 |
|
sl@0
|
99 |
test.Title();
|
sl@0
|
100 |
|
sl@0
|
101 |
RunTests();
|
sl@0
|
102 |
|
sl@0
|
103 |
return KErrNone;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|