kerneltest/e32test/pipe/t_pipe5.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\pipe\t_pipe5.cpp
       
    15 // This process has ReadDeviceData capability
       
    16 // This is supporting program for testing pipes.
       
    17 // This is used by main test file ( t_pipe.cpp) for testing
       
    18 // pipes in multiprocess environment.
       
    19 // 
       
    20 //
       
    21 
       
    22 #include <e32test.h>
       
    23 #include <e32svr.h>
       
    24 #include "rpipe.h"
       
    25 
       
    26 
       
    27 LOCAL_D RTest test(_L("t_pipe5"));
       
    28 
       
    29 _LIT(KPipeName2, "PipeWithNoCap");
       
    30 _LIT(KPipeName4, "PipeWithRWCap");
       
    31 _LIT(KPipeName5, "PipeWithComDDCap");
       
    32 _LIT(KPipeName6, "PipeWithRWComDDCap");
       
    33 _LIT(KPipeName7, "PipeWithRWComDDCapVID");
       
    34 _LIT(KPipeName8, "PipeWithRWRUCap");
       
    35 
       
    36 
       
    37 
       
    38 
       
    39 LOCAL_C void RunTests(void)
       
    40 	{
       
    41 	
       
    42 	test.Start(_L("Testing In Pipe Process 5 : Process with ReadDeviceData Capabilities"));
       
    43 	RPipe					aReader, aWriter;
       
    44 		
       
    45 	TInt		ret,aSize;
       
    46 	
       
    47 /////Part 1		
       
    48 	test.Next(_L("PIPE TEST: PipeProcess 5-1\n"));
       
    49 	ret = aReader.Open(KPipeName2,RPipe::EOpenToRead);
       
    50 	test ( ret == KErrNone);
       
    51 	
       
    52 	test.Next(_L("PIPE TEST: PipeProcess 5-2\n"));				 
       
    53 	ret = aWriter.Open(KPipeName2,RPipe::EOpenToWrite);
       
    54 	test ( ret == KErrNone);
       
    55 	
       
    56 	aReader.Close();
       
    57 	aWriter.Close();
       
    58 	
       
    59 	test.Next(_L("PIPE TEST: PipeProcess 5-3\n"));				 
       
    60 	ret = aReader.Open(KPipeName2,RPipe::EOpenToRead);
       
    61 	test ( ret == KErrNone);
       
    62 	ret = aWriter.Open(KPipeName2,RPipe::EOpenToWriteNamedPipeButFailOnNoReaders);
       
    63 	test ( ret == KErrNone);
       
    64 	
       
    65 	aReader.Close();
       
    66 	aWriter.Close();
       
    67 	
       
    68 	test.Next(_L("PIPE TEST: PipeProcess 5-4\n"));				 
       
    69 	ret = RPipe::Destroy (KPipeName2);
       
    70 	test ( ret == KErrNone);
       
    71 
       
    72 
       
    73 /////Part 2
       
    74 	test.Next(_L("PIPE TEST: PipeProcess 5-5\n"));
       
    75 	ret = aReader.Open(KPipeName4,RPipe::EOpenToRead);
       
    76 	test ( ret == KErrNone);
       
    77 	
       
    78 	test.Next(_L("PIPE TEST: PipeProcess 5-6\n"));				 
       
    79 	ret = aWriter.Open(KPipeName4,RPipe::EOpenToWrite);
       
    80 	test ( ret == KErrNone);
       
    81 	
       
    82 	aReader.Close();
       
    83 	aWriter.Close();
       
    84 		
       
    85 	test.Next(_L("PIPE TEST: PipeProcess 5-7\n"));				 
       
    86 	ret = RPipe::Destroy (KPipeName4);
       
    87 	test ( ret == KErrNone);
       
    88 	
       
    89 /////Part 3
       
    90 
       
    91 	test.Next(_L("PIPE TEST: PipeProcess 5-8\n"));
       
    92 	ret = aReader.Open(KPipeName5,RPipe::EOpenToRead);
       
    93 	test ( ret == KErrNone);
       
    94 	
       
    95 	test.Next(_L("PIPE TEST: PipeProcess 5-9\n"));				 
       
    96 	ret = aWriter.Open(KPipeName5,RPipe::EOpenToWrite);
       
    97 	test ( ret == KErrNone);
       
    98 	
       
    99 	aReader.Close();
       
   100 	aWriter.Close();
       
   101 		
       
   102 	test.Next(_L("PIPE TEST: PipeProcess 5-10\n"));				 
       
   103 	ret = RPipe::Destroy (KPipeName5);
       
   104 	test ( ret == KErrNone);
       
   105 	
       
   106 /////Part 4
       
   107 
       
   108 	test.Next(_L("PIPE TEST: PipeProcess 5-11\n"));
       
   109 	ret = aReader.Open(KPipeName6,RPipe::EOpenToRead);
       
   110 	test ( ret == KErrNone);
       
   111 	
       
   112 	test.Next(_L("PIPE TEST: PipeProcess 5-12\n"));				 
       
   113 	ret = aWriter.Open(KPipeName6,RPipe::EOpenToWrite);
       
   114 	test ( ret == KErrNone);
       
   115 	
       
   116 	aReader.Close();
       
   117 	aWriter.Close();
       
   118 		
       
   119 	test.Next(_L("PIPE TEST: PipeProcess 5-13\n"));				 
       
   120 	ret = RPipe::Destroy (KPipeName6);
       
   121 	test ( ret == KErrNone);
       
   122 	
       
   123 /////Part 5
       
   124 
       
   125 	test.Next(_L("PIPE TEST: PipeProcess 5-14\n"));
       
   126 	ret = aReader.Open(KPipeName7,RPipe::EOpenToRead);
       
   127 	test ( ret == KErrPermissionDenied);
       
   128 	
       
   129 	test.Next(_L("PIPE TEST: PipeProcess 5-15\n"));				 
       
   130 	ret = aWriter.Open(KPipeName7,RPipe::EOpenToWrite);
       
   131 	test ( ret == KErrPermissionDenied);
       
   132 	
       
   133 	aReader.Close();
       
   134 	aWriter.Close();
       
   135 		
       
   136 	test.Next(_L("PIPE TEST: PipeProcess 5-16\n"));				 
       
   137 	ret = RPipe::Destroy (KPipeName7);
       
   138 	test ( ret == KErrPermissionDenied);
       
   139 
       
   140 /////Part 6
       
   141 
       
   142 	test.Next(_L("PIPE TEST: PipeProcess 5-17\n"));
       
   143 	ret = aReader.Open(KPipeName8,RPipe::EOpenToRead);
       
   144 	test ( ret == KErrPermissionDenied);
       
   145 	
       
   146 	test.Next(_L("PIPE TEST: PipeProcess 5-18\n"));				 
       
   147 	ret = aWriter.Open(KPipeName8,RPipe::EOpenToWrite);
       
   148 	test ( ret == KErrPermissionDenied);
       
   149 	
       
   150 	aReader.Close();
       
   151 	aWriter.Close();
       
   152 		
       
   153 	test.Next(_L("PIPE TEST: PipeProcess 5-19\n"));				 
       
   154 	ret = RPipe::Destroy (KPipeName8);
       
   155 	test ( ret == KErrPermissionDenied);
       
   156 	
       
   157 /////Part 7	
       
   158 	aSize = 10;
       
   159 	ret = RPipe::Create(	aSize,
       
   160 							aReader, 
       
   161 							aWriter,
       
   162 							EOwnerProcess,//TOwnerType aTypeW
       
   163 							EOwnerProcess//TOwnerType aTypeW
       
   164 						);
       
   165 	
       
   166 	test.Next(_L("PIPE TEST: PipeProcess 5-20\n"));				 
       
   167 	test ( ret == KErrNone);
       
   168 	aReader.Close();
       
   169 	aWriter.Close();
       
   170 	
       
   171 	test.End();		
       
   172 	test.Close();
       
   173 	
       
   174 	return;
       
   175 }
       
   176 
       
   177 GLDEF_C TInt E32Main()
       
   178 {
       
   179 
       
   180 	test.Title();
       
   181 
       
   182 	RunTests();
       
   183 
       
   184 	return KErrNone;
       
   185 }
       
   186