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 #include <QtGui> |
|
19 #include <QtTest/QtTest> |
|
20 |
|
21 #include <hbapplication.h> |
|
22 #include <hbmainwindow.h> |
|
23 #include <hbframeitem.h> |
|
24 #include <hbiconitem.h> |
|
25 #include <hbstyle.h> |
|
26 #include <hbstyleoptionpushbutton.h> |
|
27 #include <hbcolorscheme.h> |
|
28 |
|
29 #include "bubbletest.h" |
|
30 #include "bubblebuttonstyle.h" |
|
31 |
|
32 class ut_BubbleButtonStyle : public QObject |
|
33 { |
|
34 Q_OBJECT |
|
35 |
|
36 private slots: |
|
37 void initTestCase(); |
|
38 void cleanupTestCase(); |
|
39 |
|
40 void testPushButtonFrame(); |
|
41 void testPushButtonIcon(); |
|
42 |
|
43 private: |
|
44 BubbleButtonStyle *mStyle; |
|
45 }; |
|
46 |
|
47 void ut_BubbleButtonStyle::initTestCase() |
|
48 { |
|
49 mStyle = new BubbleButtonStyle(); |
|
50 } |
|
51 |
|
52 void ut_BubbleButtonStyle::cleanupTestCase() |
|
53 { |
|
54 delete mStyle; |
|
55 } |
|
56 |
|
57 void ut_BubbleButtonStyle::testPushButtonFrame() |
|
58 { |
|
59 HbFrameItem* item = new HbFrameItem(); |
|
60 HbStyleOptionPushButton option; |
|
61 option.backgroundFrameDrawer = 0; |
|
62 |
|
63 // Enabled ON |
|
64 option.state |= QStyle::State_On; |
|
65 option.state |= QStyle::State_Enabled; |
|
66 |
|
67 mStyle->setButtonColor(BubbleButtonStyle::Default); |
|
68 mStyle->updatePrimitive(item,HbStyle::P_PushButton_background,&option); |
|
69 QVERIFY(item->frameDrawer().frameGraphicsName()=="qtg_fr_btn_pressed"); |
|
70 |
|
71 mStyle->setButtonColor(BubbleButtonStyle::Green); |
|
72 mStyle->updatePrimitive(item,HbStyle::P_PushButton_background,&option); |
|
73 QVERIFY(item->frameDrawer().frameGraphicsName()=="qtg_fr_btn_green_pressed"); |
|
74 |
|
75 mStyle->setButtonColor(BubbleButtonStyle::Red); |
|
76 mStyle->updatePrimitive(item,HbStyle::P_PushButton_background,&option); |
|
77 QVERIFY(item->frameDrawer().frameGraphicsName()=="qtg_fr_btn_red_pressed"); |
|
78 |
|
79 // Enabled OFF |
|
80 option.state &= ~QStyle::State_On; |
|
81 option.state |= QStyle::State_Off; |
|
82 |
|
83 mStyle->setButtonColor(BubbleButtonStyle::Default); |
|
84 mStyle->updatePrimitive(item,HbStyle::P_PushButton_background,&option); |
|
85 QVERIFY(item->frameDrawer().frameGraphicsName()=="qtg_fr_btn_normal"); |
|
86 |
|
87 mStyle->setButtonColor(BubbleButtonStyle::Green); |
|
88 mStyle->updatePrimitive(item,HbStyle::P_PushButton_background,&option); |
|
89 QVERIFY(item->frameDrawer().frameGraphicsName()=="qtg_fr_btn_green_normal"); |
|
90 |
|
91 mStyle->setButtonColor(BubbleButtonStyle::Red); |
|
92 mStyle->updatePrimitive(item,HbStyle::P_PushButton_background,&option); |
|
93 QVERIFY(item->frameDrawer().frameGraphicsName()=="qtg_fr_btn_red_normal"); |
|
94 |
|
95 // Disabled |
|
96 option.state &= ~QStyle::State_Enabled; |
|
97 mStyle->updatePrimitive(item,HbStyle::P_PushButton_background,&option); |
|
98 QVERIFY(item->frameDrawer().frameGraphicsName()=="qtg_fr_btn_disabled"); |
|
99 |
|
100 // Selected |
|
101 option.state |= QStyle::State_Selected; |
|
102 mStyle->updatePrimitive(item,HbStyle::P_PushButton_background,&option); |
|
103 QVERIFY(item->frameDrawer().frameGraphicsName()=="qtg_fr_btn_highlight"); |
|
104 |
|
105 // Active |
|
106 option.state &= ~QStyle::State_Selected; |
|
107 option.state |= QStyle::State_Active; |
|
108 mStyle->setButtonColor(BubbleButtonStyle::Default);; |
|
109 mStyle->updatePrimitive(item,HbStyle::P_PushButton_background,&option); |
|
110 QVERIFY(item->frameDrawer().frameGraphicsName()=="qtg_fr_btn_normal"); |
|
111 |
|
112 delete item; |
|
113 |
|
114 // exception type |
|
115 HbIconItem* item2 = new HbIconItem(); |
|
116 mStyle->updatePrimitive(item2,HbStyle::P_PushButton_background,&option); |
|
117 delete item2; |
|
118 } |
|
119 |
|
120 void ut_BubbleButtonStyle::testPushButtonIcon() |
|
121 { |
|
122 HbIconItem* item = new HbIconItem(); |
|
123 HbStyleOptionPushButton option; |
|
124 |
|
125 mStyle->setButtonColor(BubbleButtonStyle::Red); |
|
126 mStyle->updatePrimitive(item,HbStyle::P_PushButton_icon,&option); |
|
127 QVERIFY(item->color()==Qt::white); |
|
128 |
|
129 mStyle->setButtonColor(BubbleButtonStyle::Green); |
|
130 mStyle->updatePrimitive(item,HbStyle::P_PushButton_icon,&option); |
|
131 QVERIFY(item->color()==Qt::white); |
|
132 |
|
133 QColor color; |
|
134 color = HbColorScheme::color("qtc_button_normal"); |
|
135 mStyle->setButtonColor(BubbleButtonStyle::Default); |
|
136 mStyle->updatePrimitive(item,HbStyle::P_PushButton_icon,&option); |
|
137 QVERIFY(item->color()==color); |
|
138 } |
|
139 |
|
140 BUBBLE_TEST_MAIN(ut_BubbleButtonStyle) |
|
141 #include "ut_bubblebuttonstyle.moc" |
|