javamanager/debugapi/tsrc/src.s60/testappremover.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Tests for AppRemover class
       
    15 *
       
    16 */
       
    17 
       
    18 #include "appremover.h"
       
    19 
       
    20 #include "TestHarness.h"
       
    21 #include "logger.h"
       
    22 #include "commsmessage.h"
       
    23 
       
    24 
       
    25 using namespace std;
       
    26 using namespace java::debug;
       
    27 using namespace java::comms;
       
    28 using java::util::Uid;
       
    29 
       
    30 class TestAppRemover : public AppRemover
       
    31 {
       
    32 public:
       
    33     TestAppRemover(const Uid& aSuiteUid) : AppRemover(aSuiteUid),
       
    34             nextOperationCount(0), handleOperationCount(0) {};
       
    35     virtual ~TestAppRemover() {};
       
    36 
       
    37     virtual CommsMessage getNextOperation()
       
    38     {
       
    39         nextOperationCount++;
       
    40         return AppRemover::getNextOperation();
       
    41     };
       
    42 
       
    43     virtual void handleOperationResult(CommsMessage& aMessage)
       
    44     {
       
    45         handleOperationCount++;
       
    46         AppRemover::handleOperationResult(aMessage);
       
    47     };
       
    48 
       
    49     int nextOperationCount;
       
    50     int handleOperationCount;
       
    51 };
       
    52 
       
    53 
       
    54 TEST_GROUP(TestAppRemover)
       
    55 {
       
    56     TEST_SETUP()
       
    57     {
       
    58     }
       
    59 
       
    60     TEST_TEARDOWN()
       
    61     {
       
    62     }
       
    63 };
       
    64 
       
    65 
       
    66 TEST(TestAppRemover, uninstall)
       
    67 {
       
    68     Uid suiteUid(L"[87654321]");
       
    69     TestAppRemover installer(suiteUid);
       
    70 
       
    71     int rc = installer.uninstall();
       
    72     CHECK(rc != 0);
       
    73     CHECK(installer.nextOperationCount == 2);
       
    74     CHECK(installer.handleOperationCount == 2);
       
    75 }
       
    76 
       
    77 TEST(TestAppRemover, getNextOperation)
       
    78 {
       
    79     Uid suiteUid(L"[87654321]");
       
    80     TestAppRemover installer(suiteUid);
       
    81 
       
    82     CommsMessage msg = installer.getNextOperation();
       
    83     int operation = -1;
       
    84 
       
    85     msg >> operation;
       
    86     CHECK(operation == UNINSTALL_OPERATION);
       
    87 
       
    88     // uninstall is not done yet so next operation must be still UNINSTALL
       
    89     msg = installer.getNextOperation();
       
    90     msg >> operation;
       
    91     CHECK(operation == UNINSTALL_OPERATION);
       
    92 
       
    93     CommsMessage result;
       
    94     result << UNINSTALL_OPERATION << 0;
       
    95     installer.handleOperationResult(result);
       
    96 
       
    97     msg = installer.getNextOperation();
       
    98     msg >> operation;
       
    99     CHECK(operation == EXIT_OPERATION);
       
   100 }
       
   101 
       
   102 TEST(TestAppRemover, handleOperationResult)
       
   103 {
       
   104     CommsMessage msg;
       
   105     msg << UNINSTALL_OPERATION << 0;
       
   106 
       
   107     Uid suiteUid(L"[87654321]");
       
   108     TestAppRemover installer(suiteUid);
       
   109 
       
   110     installer.handleOperationResult(msg);
       
   111     CHECK(installer.handleOperationCount == 1);
       
   112 }
       
   113