baseport/syborg/webcamera/webcamera_app.cpp
changeset 52 0dfaca43d90e
child 124 606eafc6d6a8
equal deleted inserted replaced
51:457d682728ee 52:0dfaca43d90e
       
     1 /*
       
     2 * Copyright (c) 2010 ISB.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "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 * ISB - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: USB driver for test
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32test.h>
       
    19 #include <webcamera_driver.h>
       
    20 
       
    21 #include <e32debug.h>
       
    22 #define DP(format...) RDebug::Printf(format)
       
    23 
       
    24 LOCAL_D RTest test(_L("WebcameraDevice_TEST"));
       
    25 
       
    26 //Wins用ダミーなので実機では正式なものを使用する
       
    27 _LIT(KWebcameraPddFileName, "webcamera.pdd");
       
    28 _LIT(KWebcameraLddFileName, "ewebcamera.ldd");
       
    29 
       
    30 GLDEF_C TInt E32Main()
       
    31  {
       
    32     test.Title();
       
    33     TInt r;
       
    34     
       
    35     test.Start(_L("Load Physical Device"));
       
    36     r=User::LoadPhysicalDevice(KWebcameraPddFileName);
       
    37     test(r==KErrNone || r==KErrAlreadyExists);
       
    38 
       
    39     test.Next(_L("Load Logical Device"));
       
    40     r=User::LoadLogicalDevice(KWebcameraLddFileName);
       
    41     test(r==KErrNone || r==KErrAlreadyExists);
       
    42 //    __KHEAP_MARK;
       
    43 
       
    44 //    test.Next(_L("Open Device"));
       
    45 //    RDevice device;
       
    46 //    r=device.Open(RWebcameraDevice::Name());
       
    47 //    test(r==KErrNone);
       
    48 
       
    49     //test.Next(_L("Close Device"));
       
    50     //device.Close();
       
    51 
       
    52     test.Next(_L("Open Logical Channel"));
       
    53     RWebcameraDevice ldd;
       
    54     r=ldd.Open();
       
    55     test(r==KErrNone);
       
    56 
       
    57     test.Next(_L("Check access by wrong client"));
       
    58     RWebcameraDevice ldd2=ldd;
       
    59     r=ldd2.Duplicate(RThread(),EOwnerProcess);
       
    60     test(r==KErrAccessDenied);
       
    61 
       
    62     test.Next(_L("Check handle duplication"));
       
    63     ldd2=ldd;
       
    64     r=ldd2.Duplicate(RThread(),EOwnerThread);
       
    65     test(r==KErrNone);
       
    66     ldd2.Close();
       
    67 
       
    68     test.Next(_L("ReceiveData"));
       
    69     TRequestStatus status;
       
    70     HBufC8 * buffer = HBufC8::NewL(BUFSIZE);
       
    71     TPtr8	itempPtr(buffer->Des());
       
    72     itempPtr.SetLength(0);
       
    73     ldd.StartViewFinder(status,itempPtr);
       
    74 
       
    75     test.Next(_L("ReceiveDataCancel"));
       
    76     ldd.StopViewFinder();
       
    77     User::WaitForRequest(status);
       
    78     r=status.Int();
       
    79     test(r==KErrNone);
       
    80 	
       
    81     itempPtr.SetLength(0);
       
    82     ldd.StartViewFinder(status,itempPtr);
       
    83     User::WaitForRequest(status);
       
    84     r=status.Int();
       
    85 	test(r==KErrNone);
       
    86 	
       
    87     test.Next(_L("CaptureData"));
       
    88     HBufC8 * buffer1 = buffer;
       
    89     TPtr8	itempPtr1(buffer1->Des());
       
    90     itempPtr1.SetLength(0);
       
    91     ldd.Capture(status,itempPtr1);
       
    92     User::WaitForRequest(status);
       
    93     r=status.Int();
       
    94     test(r==KErrNone);
       
    95     
       
    96     test.Next(_L("Close Logical Channel"));
       
    97     ldd.Close();
       
    98 
       
    99 //    __KHEAP_MARKEND;
       
   100 
       
   101     test.Next(_L("Unload Logical Device"));
       
   102     r=User::FreeLogicalDevice(RWebcameraDevice::Name());
       
   103     test(r==KErrNone);
       
   104 
       
   105     test.Next(_L("Unload Physical Device"));
       
   106     TName pddName(RWebcameraDevice::Name());
       
   107     _LIT(KVariantExtension,".pdd");
       
   108     pddName.Append(KVariantExtension);
       
   109     r=User::FreePhysicalDevice(pddName);
       
   110     test(r==KErrNone);
       
   111 	
       
   112     test.End();
       
   113 
       
   114     return(0);
       
   115  }