|
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: Tests for RuntimeUI confirmation dialog icons. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.mj.impl.rt.ui; |
|
20 |
|
21 import com.nokia.mj.impl.rt.test.UnitTestSuiteCreator; |
|
22 import com.nokia.mj.impl.utils.exception.ExceptionBase; |
|
23 import com.nokia.mj.impl.rt.ui.qt.RuntimeUiQt; |
|
24 import com.nokia.mj.impl.rt.ui.RuntimeUi; |
|
25 import com.nokia.mj.impl.rt.ui.ConfirmData; |
|
26 |
|
27 import j2meunit.framework.Test; |
|
28 import j2meunit.framework.TestCase; |
|
29 import j2meunit.framework.TestMethod; |
|
30 import j2meunit.framework.TestSuite; |
|
31 |
|
32 /** |
|
33 * RuntimeUiQt icon tests. |
|
34 */ |
|
35 public class RuntimeUiQtIconTest extends TestCase implements UnitTestSuiteCreator |
|
36 { |
|
37 public TestSuite createTestSuite(String[] args) |
|
38 { |
|
39 TestSuite suite = new TestSuite(this.getClass().getName()); |
|
40 |
|
41 suite.addTest(new RuntimeUiQtIconTest("testIcons", new TestMethod() |
|
42 { |
|
43 public void run(TestCase tc) |
|
44 { |
|
45 ((RuntimeUiQtIconTest)tc).testIcons(); |
|
46 } |
|
47 })); |
|
48 |
|
49 return suite; |
|
50 } |
|
51 |
|
52 public RuntimeUiQtIconTest() |
|
53 { |
|
54 } |
|
55 |
|
56 public RuntimeUiQtIconTest(String aTestName, TestMethod aTestMethod) |
|
57 { |
|
58 super(aTestName, aTestMethod); |
|
59 } |
|
60 |
|
61 public void assertFalse(String aMsg, boolean aCondition) |
|
62 { |
|
63 assertTrue(aMsg, !aCondition); |
|
64 } |
|
65 |
|
66 // End j2meunit test framework setup |
|
67 |
|
68 protected void setUp() |
|
69 { |
|
70 } |
|
71 |
|
72 protected void tearDown() |
|
73 { |
|
74 } |
|
75 |
|
76 private void testIcons() |
|
77 { |
|
78 doTest(new RuntimeUiQt()); |
|
79 } |
|
80 |
|
81 private void doTest(RuntimeUi runtimeUi) |
|
82 { |
|
83 boolean answerAvailable = false; |
|
84 |
|
85 // Check untrusted icon. |
|
86 ConfirmData confirmData = new ConfirmData( |
|
87 "Check untrusted icon. If wrong choose DENY", new String[] {"allow", "deny"}, 1); |
|
88 runtimeUi.setIdentified(false); |
|
89 answerAvailable = runtimeUi.confirm("MyFavouriteAplication", confirmData); |
|
90 |
|
91 assertTrue(answerAvailable && confirmData.getAnswer() == 0); |
|
92 |
|
93 // Check trusted icon. |
|
94 confirmData = new ConfirmData( |
|
95 "Check trusted icon. If wrong choose DENY", new String[] {"allow", "deny"}, 1); |
|
96 runtimeUi.setIdentified(true); |
|
97 answerAvailable = runtimeUi.confirm("MyFavouriteAplication", confirmData); |
|
98 assertTrue(answerAvailable && confirmData.getAnswer() == 0); |
|
99 |
|
100 runtimeUi.destroy(); |
|
101 } |
|
102 } |