contentstorage/camificonengine/tsrc/t_camificonengine/src/T_camificonengine.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     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 /*
       
    18  * T_camificonengine.cpp
       
    19  *
       
    20  *  Created on: 2010-08-10
       
    21  *      Author:
       
    22  */
       
    23 
       
    24 //  CLASS HEADERS
       
    25 
       
    26 #include <QPainter>
       
    27 #include <QIconEnginePlugin>
       
    28 
       
    29 #include "T_camificonengine.h"
       
    30 #include "camificonengine.h"
       
    31 #include "cambmiconengine.h"
       
    32 
       
    33 class CaMifIconPlugin : public QIconEnginePluginV2
       
    34 {
       
    35 public:
       
    36     QStringList keys() const;
       
    37     QIconEngineV2 *create(const QString &filename = QString());
       
    38 };
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 void T_CaMifIconEngine::initEngine()
       
    44 {
       
    45     CaMifIconPlugin plugin;
       
    46     QStringList keys;
       
    47     keys << "mif" << "mbm";
       
    48     QVERIFY(plugin.keys() == keys);
       
    49     QIconEngineV2 *engine =
       
    50         plugin.create("c:/testing/data/t_camificonengine/example.mbm");
       
    51     QVERIFY(engine);
       
    52     delete engine;
       
    53     engine = NULL;
       
    54 }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void T_CaMifIconEngine::mifIconKey()
       
    60 {
       
    61     CaMifIconEngine engine;
       
    62     QCOMPARE(engine.key(), QString("mif"));
       
    63 }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void T_CaMifIconEngine::mbmIconKey()
       
    69 {
       
    70     CaMbmIconEngine engine;
       
    71     QCOMPARE(engine.key(), QString("mbm"));
       
    72 }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void T_CaMifIconEngine::mifIconAddFile()
       
    79 {
       
    80     CaMifIconEngine engine;
       
    81     QSize testSize(1, 1);
       
    82     engine.addFile("c:/testing/data/t_camificonengine/example.mif",
       
    83         testSize, QIcon::Normal, QIcon::On);
       
    84     engine.addFile("not important", testSize, QIcon::Normal, QIcon::On);
       
    85     QSize size = engine.actualSize(testSize, QIcon::Normal, QIcon::On);
       
    86     QVERIFY(size == testSize);
       
    87 }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void T_CaMifIconEngine::mbmIconAddFile()
       
    94 {
       
    95     CaMbmIconEngine engine;
       
    96     QSize testSize(1, 1);
       
    97     engine.addFile("c:/testing/data/t_camificonengine/example.mbm",
       
    98         testSize, QIcon::Normal, QIcon::On);
       
    99     engine.addFile("not important", testSize, QIcon::Normal, QIcon::On);
       
   100     QSize size = engine.actualSize(testSize, QIcon::Normal, QIcon::On);
       
   101     QVERIFY(size == testSize);
       
   102 }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void T_CaMifIconEngine::mifIconPixmap()
       
   109 {
       
   110     CaMifIconEngine engine;
       
   111     QSize testSize(1, 1);
       
   112     engine.addFile("c:/testing/data/t_camificonengine/example.mif",
       
   113         testSize, QIcon::Normal, QIcon::On);
       
   114     QPixmap pixmap = engine.pixmap(testSize, QIcon::Normal, QIcon::On);
       
   115     QSize size = pixmap.size();
       
   116     QVERIFY(size.width()>0);
       
   117     QVERIFY(size.height()>0);
       
   118     engine.addPixmap(pixmap, QIcon::Normal, QIcon::On);
       
   119     QPainter painter;
       
   120     engine.paint(&painter, QRect(QPoint(0, 0), size),
       
   121         QIcon::Normal, QIcon::On);
       
   122     QIconEngineV2 *clonedEngine = engine.clone();
       
   123     QVERIFY(size ==
       
   124         clonedEngine->pixmap(testSize, QIcon::Normal, QIcon::On).size());
       
   125 }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void T_CaMifIconEngine::mbmIconPixmap()
       
   132 {
       
   133     CaMbmIconEngine engine;
       
   134     QSize testSize(1, 1);
       
   135     engine.addFile("c:/testing/data/t_camificonengine/example.mbm",
       
   136         testSize, QIcon::Normal, QIcon::On);
       
   137     QPixmap pixmap = engine.pixmap(testSize, QIcon::Normal, QIcon::On);
       
   138     QSize size = pixmap.size();
       
   139     QVERIFY(size.width()>0);
       
   140     QVERIFY(size.height()>0);
       
   141     engine.addPixmap(pixmap, QIcon::Normal, QIcon::On);
       
   142     QPainter painter;
       
   143     engine.paint(&painter, QRect(QPoint(0, 0), size),
       
   144         QIcon::Normal, QIcon::On);
       
   145     QIconEngineV2 *clonedEngine = engine.clone();
       
   146     QVERIFY(size ==
       
   147         clonedEngine->pixmap(testSize, QIcon::Normal, QIcon::On).size());
       
   148 }
       
   149 
       
   150 QTEST_MAIN(T_CaMifIconEngine)