camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakestillcapturecontrol.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 23 61bc0f252b2b
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
     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:
       
    15 *
       
    16 */
       
    17 #include "cxefakestillcapturecontrol.h"
       
    18 #include "cxefakequalitypresets.h"
       
    19 #include "cxeimagedataqueuesymbian.h"
       
    20 #include "cxefilenamegeneratorsymbian.h"
       
    21 #include "cxutils.h"
       
    22 #include "cxestillimagesymbian.h"
       
    23 #include "cxestate.h"
       
    24 
       
    25 
       
    26 CxeFakeStillCaptureControl::CxeFakeStillCaptureControl()
       
    27     : CxeStateMachine("CxeFakeStillCaptureControl")
       
    28 {
       
    29     CX_DEBUG_ENTER_FUNCTION();
       
    30 
       
    31     initializeStates();
       
    32 
       
    33     CX_DEBUG_EXIT_FUNCTION();
       
    34 }
       
    35 
       
    36 CxeFakeStillCaptureControl::~CxeFakeStillCaptureControl()
       
    37 {
       
    38     CX_DEBUG_IN_FUNCTION();
       
    39 }
       
    40 
       
    41 void CxeFakeStillCaptureControl::capture()
       
    42 {
       
    43     CX_DEBUG_IN_FUNCTION();
       
    44 }
       
    45 
       
    46 CxeStillCaptureControl::State CxeFakeStillCaptureControl::state() const
       
    47 {
       
    48     return static_cast<State>(stateId());
       
    49 }
       
    50 
       
    51 void CxeFakeStillCaptureControl::setState(CxeStillCaptureControl::State newState)
       
    52 {
       
    53     CxeStateMachine::setState(newState, CxeError::None);
       
    54 }
       
    55 
       
    56 int CxeFakeStillCaptureControl::imageCount() const
       
    57 {
       
    58     CX_DEBUG_IN_FUNCTION();
       
    59     return 0;
       
    60 }
       
    61 
       
    62 void CxeFakeStillCaptureControl::reset()
       
    63 {
       
    64     CX_DEBUG_IN_FUNCTION();
       
    65 }
       
    66 
       
    67 void CxeFakeStillCaptureControl::cancelAll()
       
    68 {
       
    69     CX_DEBUG_IN_FUNCTION();
       
    70 }
       
    71 
       
    72 void CxeFakeStillCaptureControl::setMode(CaptureMode mode)
       
    73 {
       
    74     Q_UNUSED(mode);
       
    75     CX_DEBUG_IN_FUNCTION();
       
    76 }
       
    77 
       
    78 CxeStillCaptureControl::CaptureMode CxeFakeStillCaptureControl::mode() const
       
    79 {
       
    80     return SingleImageCapture;
       
    81 }
       
    82 
       
    83 void CxeFakeStillCaptureControl::init()
       
    84 {
       
    85     CX_DEBUG_IN_FUNCTION();
       
    86     mCallHistory.append(Init);
       
    87 }
       
    88 
       
    89 void CxeFakeStillCaptureControl::deinit()
       
    90 {
       
    91     CX_DEBUG_IN_FUNCTION();
       
    92     mCallHistory.append(Deinit);
       
    93 }
       
    94 
       
    95 CxeStillImage &CxeFakeStillCaptureControl::operator[](int index)
       
    96 {
       
    97     Q_UNUSED(index);
       
    98 
       
    99     CX_DEBUG_ENTER_FUNCTION();
       
   100 
       
   101     // There is no fake class for CxeStillImage, because it's not used
       
   102     // in any tests. Calling this always crashes.
       
   103 
       
   104     CxeStillImage *stillImage = 0;
       
   105 
       
   106     CX_ASSERT_ALWAYS(stillImage); // Always panics
       
   107 
       
   108     CX_DEBUG_EXIT_FUNCTION();
       
   109     return *stillImage;
       
   110 }
       
   111 
       
   112 CxeImageDataQueue &CxeFakeStillCaptureControl::imageDataQueue()
       
   113 {
       
   114     CX_DEBUG_ENTER_FUNCTION();
       
   115 
       
   116     // There is no fake class for CxeImageDataQueue, because it's not used
       
   117     // in any tests. Calling this always crashes.
       
   118 
       
   119     CxeImageDataQueue *imageDataQueue = 0;
       
   120 
       
   121     CX_ASSERT_ALWAYS(imageDataQueue); // Always panics
       
   122 
       
   123     CX_DEBUG_EXIT_FUNCTION();
       
   124     return *imageDataQueue;
       
   125 }
       
   126 
       
   127 void CxeFakeStillCaptureControl::handleStateChanged(
       
   128         int newStateId, CxeError::Id error)
       
   129 {
       
   130     emit stateChanged(static_cast<State>(newStateId), error);
       
   131 }
       
   132 
       
   133 void CxeFakeStillCaptureControl::initializeStates()
       
   134 {
       
   135     // The fake state machine has more relaxed state transition checks
       
   136     // for testing purposes.
       
   137     int anyState = (Uninitialized | Ready | Capturing);
       
   138 
       
   139     // addState( id, name, allowed next states )
       
   140     addState(new CxeState(Uninitialized , "Uninitialized", anyState));
       
   141     addState(new CxeState(Ready , "Ready", anyState));
       
   142     addState(new CxeState(Capturing , "Capturing", anyState));
       
   143 
       
   144     setInitialState(Uninitialized);
       
   145 }
       
   146 
       
   147 QList<CxeFakeStillCaptureControl::MethodIndex> CxeFakeStillCaptureControl::callHistory() const
       
   148 {
       
   149     return mCallHistory;
       
   150 }
       
   151 
       
   152 void CxeFakeStillCaptureControl::resetCallHistory()
       
   153 {
       
   154     mCallHistory.clear();
       
   155 }
       
   156 
       
   157 QList<CxeImageDetails> CxeFakeStillCaptureControl::supportedImageQualities()
       
   158 {
       
   159     QList<CxeImageDetails> list;
       
   160     list.append(CxeFakeQualityPresets::fakeImageDetails());
       
   161     return list;
       
   162 }
       
   163 
       
   164 /*
       
   165 * Returns the number of images left for the current image quality setting
       
   166 */
       
   167 int CxeFakeStillCaptureControl::imagesLeft()
       
   168 {
       
   169     return 1000;
       
   170 }
       
   171