camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxememorymonitor/unittest_cxememorymonitor.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 23 61bc0f252b2b
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
     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:
       
    15 *
       
    16 */
       
    17 #include <QDate>
       
    18 #include <QTest>
       
    19 #include <QDebug>
       
    20 #include <QThread>
       
    21 
       
    22 #include "cxetestutils.h"
       
    23 #include "cxefakefeaturemanager.h"
       
    24 #include "cxememorymonitor.h"
       
    25 #include "unittest_cxememorymonitor.h"
       
    26 
       
    27 UnitTestCxeMemoryMonitor::UnitTestCxeMemoryMonitor()
       
    28     : mMemoryMonitor(NULL),
       
    29       mFakeFeatureManager(NULL)
       
    30 {
       
    31 }
       
    32 
       
    33 UnitTestCxeMemoryMonitor::~UnitTestCxeMemoryMonitor()
       
    34 {
       
    35     cleanup();
       
    36 }
       
    37 
       
    38 // Run before each individual test case
       
    39 void UnitTestCxeMemoryMonitor::init()
       
    40 {
       
    41     CX_DEBUG_ENTER_FUNCTION();
       
    42 
       
    43     mFakeFeatureManager = new CxeFakeFeatureManager();
       
    44     mMemoryMonitor = new CxeMemoryMonitor(*mFakeFeatureManager);
       
    45 
       
    46     CX_DEBUG_EXIT_FUNCTION();
       
    47 }
       
    48 
       
    49 // Run after each individual test case
       
    50 void UnitTestCxeMemoryMonitor::cleanup()
       
    51 {
       
    52     CX_DEBUG_ENTER_FUNCTION();
       
    53     delete mMemoryMonitor;
       
    54     mMemoryMonitor = NULL;
       
    55 
       
    56     delete mFakeFeatureManager;
       
    57     mFakeFeatureManager = NULL;
       
    58 
       
    59     CX_DEBUG_EXIT_FUNCTION();
       
    60 }
       
    61 
       
    62 void UnitTestCxeMemoryMonitor::testFree()
       
    63 {
       
    64     CX_DEBUG_ENTER_FUNCTION();
       
    65     QVERIFY(mMemoryMonitor->free() > 0);
       
    66     CX_DEBUG_EXIT_FUNCTION();
       
    67 }
       
    68 
       
    69 void UnitTestCxeMemoryMonitor::testStartMonitoring()
       
    70 {
       
    71     CX_DEBUG_ENTER_FUNCTION();
       
    72     mMemoryMonitor->startMonitoring();
       
    73     QVERIFY(mMemoryMonitor->free() > 0);
       
    74     CX_DEBUG_EXIT_FUNCTION();
       
    75 }
       
    76 
       
    77 void UnitTestCxeMemoryMonitor::testStopMonitoring()
       
    78 {
       
    79     CX_DEBUG_ENTER_FUNCTION();
       
    80     mMemoryMonitor->stopMonitoring();
       
    81     QVERIFY(mMemoryMonitor->free() > 0);
       
    82     CX_DEBUG_EXIT_FUNCTION();
       
    83 }
       
    84 
       
    85 void UnitTestCxeMemoryMonitor::testStartStopMonitoring()
       
    86 {
       
    87     CX_DEBUG_ENTER_FUNCTION();
       
    88     mMemoryMonitor->startMonitoring();
       
    89     mMemoryMonitor->stopMonitoring();
       
    90     QVERIFY(mMemoryMonitor->free() > 0);
       
    91     CX_DEBUG_EXIT_FUNCTION();
       
    92 }
       
    93 
       
    94 // main() function - Need event loop for waiting signals,
       
    95 // so can't use QTEST_APPLESS_MAIN.
       
    96 QTEST_MAIN(UnitTestCxeMemoryMonitor);