usbmgmt/usbmgrtest/t_whcm_cc/src/t_whcm_cc.cpp
branchRCL_3
changeset 15 f92a4f87e424
parent 0 c9bc50fca66e
child 16 012cc2ee6408
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
   115 			   }
   115 			   }
   116 			   test.Printf(_L("   Connected to USB Manager.\n"));
   116 			   test.Printf(_L("   Connected to USB Manager.\n"));
   117 			   current_test_state = EUSBManConnected;
   117 			   current_test_state = EUSBManConnected;
   118 			   break;
   118 			   break;
   119 		  case EUSBManConnected:
   119 		  case EUSBManConnected:
   120 			   // Register as primary client.
       
   121 			   // *** Obsolete ***
       
   122 			   /*
       
   123 			   r = usbman->RegisterAsPrimarySession();
       
   124 			   if (r != KErrNone)
       
   125 			   {
       
   126 					test.Printf(_L("    Failed to register as primary client. Error = %d\n"), r);
       
   127 					return r;
       
   128 			   }
       
   129 			   test.Printf(_L("    Registered as primary client.\n"));
       
   130 			   */
       
   131 			   current_test_state = EPrimaryRegistered;
   120 			   current_test_state = EPrimaryRegistered;
   132 			   break;
   121 			   break;
   133 		  default:
   122 		  default:
   134 			   break;
   123 			   break;
   135 		  }
   124 		  }
   158 			   usbman->Stop(status);
   147 			   usbman->Stop(status);
   159 			   User::WaitForRequest(status);
   148 			   User::WaitForRequest(status);
   160 			   current_test_state = EPrimaryRegistered;
   149 			   current_test_state = EPrimaryRegistered;
   161 			   break;
   150 			   break;
   162 		  case EPrimaryRegistered:
   151 		  case EPrimaryRegistered:
   163 			   // *** Obsolete ***
       
   164 			   // usbman->DeregisterAsPrimarySession();
       
   165 			   current_test_state = EUSBManConnected;
   152 			   current_test_state = EUSBManConnected;
   166 			   break;
   153 			   break;
   167 		  case EUSBManConnected:
   154 		  case EUSBManConnected:
   168 			   // Don't need to disconnect.
   155 			   // Don't need to disconnect.
   169 			   current_test_state = EUSBManCreated;
   156 			   current_test_state = EUSBManCreated;
   235 
   222 
   236 	current_test_state = EUSBManStarted;
   223 	current_test_state = EUSBManStarted;
   237 	return KErrNone;
   224 	return KErrNone;
   238 	}
   225 	}
   239 
   226 
   240 
       
   241 /**
       
   242  * Executes test A2 (as detailed in the USB Manager Test Specification).
       
   243  * No longer a relevant test.
       
   244  */
       
   245 /*static TInt RunTest_A2()
       
   246 	{
       
   247 	TInt r;
       
   248 
       
   249 	test.Next(_L("Test A2.\n"));
       
   250 
       
   251 	// Perform common startup
       
   252 	current_test_state = EStart;
       
   253 	r = CommonStart();
       
   254 	if (r != KErrNone)
       
   255 		 return r;
       
   256 
       
   257 	// Start the USB Manager
       
   258 	TRequestStatus status;
       
   259 	test.Printf(_L("Starting.\n"));
       
   260 	usbman->Start(status);
       
   261 
       
   262 	// Wait for specific time (has to be less than the time to process a start request)
       
   263 	timer.After(status, CANCEL_START_REQ_DELAY);
       
   264 	User::WaitForRequest(status);
       
   265 
       
   266 	// Cancel the start request
       
   267 	test.Printf(_L("Cancelling.\n"));
       
   268 	usbman->StartCancel();
       
   269 
       
   270 	// Check service status
       
   271 	test.Printf(_L("Checking service status.\n"));
       
   272 	r = CheckServiceState(EUsbServiceIdle);
       
   273 	if ( r != KErrNone)
       
   274 		 return r;
       
   275 
       
   276 	return KErrNone;
       
   277 	}
       
   278 */
       
   279 /**
   227 /**
   280  * Executes test A3 (as detailed in the USB Manager Test Specification).
   228  * Executes test A3 (as detailed in the USB Manager Test Specification).
   281  */
   229  */
   282 static TInt RunTest_A3()
   230 static TInt RunTest_A3()
   283 	{
   231 	{
   311 
   259 
   312 	return KErrNone;
   260 	return KErrNone;
   313 	}
   261 	}
   314 
   262 
   315 /**
   263 /**
   316  * Executes test A4 (as detailed in the USB Manager Test Specification).
       
   317  * No longer a relevant test.
       
   318  */
       
   319 /*static TInt RunTest_A4()
       
   320 	{
       
   321 	TInt r;
       
   322 
       
   323 	test.Next(_L("Test A4.\n"));
       
   324 
       
   325 	// Perform common startup
       
   326 	current_test_state = EStart;
       
   327 	r = CommonStart();
       
   328 	if (r != KErrNone)
       
   329 		 return r;
       
   330 
       
   331 	// Start the USB Manager
       
   332 	TRequestStatus status, timerStatus;
       
   333 	usbman->Start(status);
       
   334 	User::WaitForRequest(status);
       
   335 	test.Printf(_L("Start completed with status %d\n"), status.Int());
       
   336 	current_test_state = EUSBManStarted;
       
   337 
       
   338 	// Stop the USB Manager
       
   339 	usbman->Stop(status);
       
   340 
       
   341 	// Wait for specific time (has to be less than the time to process a start request)
       
   342 	timer.After(timerStatus, CANCEL_STOP_REQ_DELAY);
       
   343 	User::WaitForRequest(status, timerStatus);
       
   344 
       
   345 	// Cancel the stop request
       
   346 	usbman->StopCancel();
       
   347 
       
   348 	// Check service status
       
   349 	r = CheckServiceState(EUsbServiceStarted);
       
   350 	if ( r != KErrNone)
       
   351 		 return r;
       
   352 
       
   353 	return KErrNone;
       
   354 	}
       
   355 */
       
   356 /**
       
   357  * Main function.
   264  * Main function.
   358  *
   265  *
   359  * Runs all the tests in order.
   266  * Runs all the tests in order.
   360  */
   267  */
   361 void mainL()
   268 void mainL()
   371 	}
   278 	}
   372 	else
   279 	else
   373 		test.Printf(_L("Test A1 passed.\n\n"));
   280 		test.Printf(_L("Test A1 passed.\n\n"));
   374 	CommonCleanup();
   281 	CommonCleanup();
   375 
   282 
   376 /*	Depreciated test.
       
   377 	err=RunTest_A2();
       
   378 	if (err != KErrNone)
       
   379 	{
       
   380 		test.Printf(_L("Test A2 failed, code: %d\n\n"), err);
       
   381 	}
       
   382 	else
       
   383 		test.Printf(_L("Test A2 passed.\n\n"));
       
   384 	CommonCleanup();
       
   385 */
       
   386 	err=RunTest_A3();
   283 	err=RunTest_A3();
   387 	if (err != KErrNone)
   284 	if (err != KErrNone)
   388 	{
   285 	{
   389 		test.Printf(_L("Test A3 failed, code: %d\n\n"), err);
   286 		test.Printf(_L("Test A3 failed, code: %d\n\n"), err);
   390 	}
   287 	}
   391 	else
   288 	else
   392 		test.Printf(_L("Test A3 passed.\n\n"));
   289 		test.Printf(_L("Test A3 passed.\n\n"));
   393 	CommonCleanup();
   290 	CommonCleanup();
   394 
   291 
   395 /*	Depreciated test.
   292 
   396 	err=RunTest_A4();
       
   397 	if (err != KErrNone)
       
   398 	{
       
   399 		test.Printf(_L("Test A4 failed, code: %d\n\n"), err);
       
   400 	}
       
   401 	else
       
   402 		test.Printf(_L("Test A4 passed.\n\n"));
       
   403 	CommonCleanup();
       
   404 */
       
   405 	// Tests finished
   293 	// Tests finished
   406     }
   294     }
   407 
   295 
   408 /**
   296 /**
   409  * Entry point.
   297  * Entry point.