javauis/coreui/tsrc/testcoreui/javasrc/com/nokia/mj/impl/coreuitest/CoreUiImpl.java
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
child 84 0553e2305d00
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
     1 /*
       
     2 * Copyright (c) 2010 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: Java side Core UI tester.
       
    15 *
       
    16 */
       
    17 package com.nokia.mj.impl.coreuitest;
       
    18 
       
    19 import com.nokia.mj.impl.utils.Uid;
       
    20 import com.nokia.mj.impl.coreui.CoreUi;
       
    21 
       
    22 
       
    23 /**
       
    24  * A gate to CoreUi test implementation.
       
    25  */
       
    26 public class CoreUiImpl extends CoreUi
       
    27 {
       
    28     private static int[] mCounters = new int[6];
       
    29 
       
    30     static void resetCounters()
       
    31     {
       
    32         for (int i = 0; i < mCounters.length; ++i)
       
    33         {
       
    34             mCounters[i] = 0;
       
    35         }
       
    36     }
       
    37 
       
    38     static void checkCounters(int[] expected)
       
    39     {
       
    40         if (expected.length != mCounters.length)
       
    41         {
       
    42             throw new RuntimeException("expected.length != mCounters.length");
       
    43         }
       
    44         for (int i = 0; i < mCounters.length; ++i)
       
    45         {
       
    46             if (mCounters[i] != expected[i])
       
    47             {
       
    48                 throw new RuntimeException("Index: " + i + " didn't match. Expected: " +
       
    49                                            expected[i] + ", was: " + mCounters[i]);
       
    50             }
       
    51         }
       
    52     }
       
    53 
       
    54     protected boolean connectToUiImpl()
       
    55     {
       
    56         mCounters[0]++;
       
    57         return true;
       
    58     }
       
    59 
       
    60     private static Uid     mUid = null;
       
    61     private static boolean mBackGroundStart = false;
       
    62 
       
    63     static void createUiImplCheck(Uid uid, boolean backGroundStart)
       
    64     {
       
    65         if (uid != mUid)
       
    66         {
       
    67             throw new RuntimeException("createUiImplCheck uid mismatch");
       
    68         }
       
    69         if (backGroundStart != mBackGroundStart)
       
    70         {
       
    71             throw new RuntimeException("createUiImplCheck backGroundStart mismatch");
       
    72         }
       
    73         mUid = null;
       
    74         mBackGroundStart = false;
       
    75     }
       
    76 
       
    77     protected void createUiImpl(Uid uid, boolean backGroundStart)
       
    78     {
       
    79         mCounters[1]++;
       
    80         mUid = uid;
       
    81         mBackGroundStart = backGroundStart;
       
    82     }
       
    83 
       
    84     protected void shutdownRequestImpl()
       
    85     {
       
    86         mCounters[2]++;
       
    87     }
       
    88 
       
    89     protected void foregroundRequestImpl()
       
    90     {
       
    91         mCounters[3]++;
       
    92     }
       
    93 
       
    94     protected boolean isUiInForegroundImpl()
       
    95     {
       
    96         mCounters[4]++;
       
    97         return true;
       
    98     }
       
    99 
       
   100     private static boolean mHide = false;
       
   101 
       
   102     static void hideApplicationImplCheck(boolean hide)
       
   103     {
       
   104         if (mHide != hide)
       
   105         {
       
   106             throw new RuntimeException("hideApplicationImplCheck hide mismatch");
       
   107         }
       
   108         mHide = false;
       
   109     }
       
   110 
       
   111     protected void hideApplicationImpl(boolean hide)
       
   112     {
       
   113         mCounters[5]++;
       
   114         mHide = hide;
       
   115     }
       
   116 }