|
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 |
|
18 import java.io.*; |
|
19 import javax.microedition.lcdui.*; |
|
20 import javax.microedition.midlet.*; |
|
21 |
|
22 public class RmsBenchmarkMidlet extends MIDlet implements CommandListener |
|
23 { |
|
24 private static final Command EXIT_CMD = new Command("Exit", 6, 0); |
|
25 private static final Command RUN_CMD = new Command("Quick Test", 6, 0); |
|
26 private static final Command FULL_CMD = new Command("Full Test", 6, 0); |
|
27 |
|
28 private Form myForm; |
|
29 private Display myDisplay; |
|
30 |
|
31 private BenchmarkRunner myBenchmarkRunner; |
|
32 private boolean myTestRunning = false; |
|
33 |
|
34 public RmsBenchmarkMidlet() |
|
35 { |
|
36 myDisplay = Display.getDisplay(this); |
|
37 myForm = new Form("RMS Benchmark"); |
|
38 myBenchmarkRunner = new BenchmarkRunner(this); |
|
39 } |
|
40 |
|
41 protected void pauseApp() |
|
42 { |
|
43 } |
|
44 |
|
45 public void destroyApp(boolean flag) |
|
46 { |
|
47 notifyDestroyed(); |
|
48 } |
|
49 |
|
50 public void startApp() |
|
51 { |
|
52 myDisplay.setCurrent(myForm); |
|
53 if (!myTestRunning) |
|
54 { |
|
55 myTestRunning = true; |
|
56 myBenchmarkRunner.start(); |
|
57 } |
|
58 } |
|
59 |
|
60 public void updateForm(String txt) |
|
61 { |
|
62 myForm.append(txt + "\n"); |
|
63 } |
|
64 |
|
65 public void testsCompleted() |
|
66 { |
|
67 System.out.println("RmsBenchmarkMidlet.testsCompleted()"); |
|
68 myTestRunning = false; |
|
69 updateForm("Tests completed!"); |
|
70 myForm.addCommand(EXIT_CMD); |
|
71 myForm.addCommand(RUN_CMD); |
|
72 myForm.addCommand(FULL_CMD); |
|
73 myForm.setCommandListener(this); |
|
74 } |
|
75 |
|
76 public void commandAction(Command command, Displayable displayable) |
|
77 { |
|
78 if (command == EXIT_CMD) |
|
79 { |
|
80 destroyApp(true); |
|
81 notifyDestroyed(); |
|
82 } |
|
83 else if (command == RUN_CMD) |
|
84 { |
|
85 System.out.println("RUN_CMD"); |
|
86 if (!myTestRunning) |
|
87 { |
|
88 System.out.println("Running quick benchmarks"); |
|
89 myTestRunning = true; |
|
90 myBenchmarkRunner.start(); |
|
91 } |
|
92 myForm.deleteAll(); |
|
93 } |
|
94 else if (command == FULL_CMD) |
|
95 { |
|
96 System.out.println("FULL_CMD"); |
|
97 if (!myTestRunning) |
|
98 { |
|
99 System.out.println("Running full benchmarks"); |
|
100 myTestRunning = true; |
|
101 myBenchmarkRunner.startFull(); |
|
102 } |
|
103 myForm.deleteAll(); |
|
104 } |
|
105 } |
|
106 } |