TestMIDLet Coverage Report

Metrics: CCN: 2,111 Methods: 9
NCSS: 6,444 Classes: -
JVDC: 0% Packages: -
Need help?
Package # Classes Line Coverage Branch Coverage Method Coverage
KITExcellence 14
88.5% 
89.5% 
89.1% 

Class Line Coverage Branch Coverage Method Coverage
EliteSolutionsMIDLet.MyModel
93.3% 
100% 
100% 

 1  
 package KITExcellence;
 2  
 import java.io.IOException;
 3  
 
 4  
 import javax.microedition.lcdui.Command;
 5  
 import javax.microedition.lcdui.CommandListener;
 6  
 import javax.microedition.lcdui.Display;
 7  
 import javax.microedition.lcdui.Displayable;
 8  
 import javax.microedition.lcdui.Graphics;
 9  
 import javax.microedition.midlet.MIDlet;
 10  
 import javax.microedition.midlet.MIDletStateChangeException;
 11  
 
 12  
 public class EliteSolutionsMIDLet extends MIDlet implements CommandListener {
 13  
 
 14  
         private GameEngine engine;
 15  
         private SpriteManager manager;
 16  
         private Display    display;
 17  
         private MyViewB           viewB;
 18  
         private Command           exit;
 19  
         private Command           pause;
 20  
         private Command           resume;
 21  
         
 22  
         public EliteSolutionsMIDLet() throws IOException {
 23  
                 this.display = Display.getDisplay(this);
 24  
                 
 25  
                 MyModel model = new MyModel(10, 100, 50, 50, 50);
 26  
                 this.engine = new GameEngine(model, 50);
 27  
                 manager = new SpriteManager(engine.getTimer());
 28  
                 try {
 29  
                         this.viewB = new MyViewB(model, "tux");
 30  
                         this.engine.attach(viewB);
 31  
                 } catch(Exception e) {
 32  
                         System.out.println("Exception: " + e.getMessage());
 33  
                         e.printStackTrace();
 34  
                 }
 35  
                 
 36  
                 Displayable drawingArea = this.engine.getDrawingArea(); 
 37  
                         
 38  
                 drawingArea.setCommandListener(this);
 39  
                 
 40  
                 this.resume = new Command("Resume", Command.SCREEN, 2);
 41  
                 drawingArea.addCommand(this.resume);
 42  
 
 43  
                 this.pause = new Command("Pause", Command.SCREEN, 1);
 44  
                 drawingArea.addCommand(this.pause);
 45  
                 
 46  
                 this.exit = new Command("Exit", Command.EXIT, 1);
 47  
                 drawingArea.addCommand(this.exit);
 48  
         }
 49  
         
 50  
         /* (non-Javadoc)
 51  
          * @see javax.microedition.midlet.MIDlet#startApp()
 52  
          */
 53  
         protected void startApp() throws MIDletStateChangeException {
 54  
                 this.display.setCurrent(this.engine.getDrawingArea());
 55  
                 System.err.println("startApp called");                
 56  
                 this.engine.start();
 57  
         }
 58  
         
 59  
         /* (non-Javadoc)
 60  
          * @see javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command, javax.microedition.lcdui.Displayable)
 61  
          */
 62  
         public void commandAction(Command c, Displayable d) {
 63  
                 if (c == this.exit) {
 64  
                         System.err.println("Exit...");
 65  
                         try {
 66  
                                 destroyApp(true);
 67  
                         } catch (MIDletStateChangeException e) {
 68  
                                 return;
 69  
                         }
 70  
                         notifyDestroyed();
 71  
                 } else
 72  
                 if (c == this.resume) {
 73  
                         this.engine.resume();
 74  
                 } else
 75  
                 if (c == this.pause) {
 76  
                         this.engine.pause();
 77  
                 }
 78  
         }
 79  
         
 80  
         /* (non-Javadoc)
 81  
          * @see javax.microedition.midlet.MIDlet#destroyApp(boolean)
 82  
          */
 83  
         protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
 84  
                 System.err.println("destroyApp called");
 85  
         }
 86  
 
 87  
         /* (non-Javadoc)
 88  
          * @see javax.microedition.midlet.MIDlet#pauseApp()
 89  
          */
 90  
         protected void pauseApp() {
 91  
                 System.err.println("pauseApp called");
 92  
         }
 93  
         
 94  
         private class MyViewB implements GameView {
 95  
 
 96  
                 private MyModel model;
 97  
                 private Sprite  sprite;
 98  
                 
 99  
                 public MyViewB(MyModel model, String spriteName) throws IOException {
 100  
                         this.model = model;
 101  
                         sprite = manager.createSprite(spriteName);
 102  
                 }
 103  
                 
 104  
                 public void render(Graphics g) {
 105  
                         sprite.draw(g, (int) model.x, (int) model.y);
 106  
                 }
 107  
         }
 108  
         
 109  
         private class MyModel implements GameModel {
 110  
 
 111  
                 private float speedx;
 112  
                 private float speedy;
 113  
                 
 114  
                 float x, y;
 115  
                 int w, h;
 116  
                 
 117  1
                 public MyModel(int x, int y, int w, int h, int speed) {
 118  1
                         this.x = x;
 119  1
                         this.y = y;
 120  1
                         this.w = w;
 121  1
                         this.h = h;
 122  
                         
 123  1
                         this.speedx = speed;
 124  1
                         this.speedy = 0;
 125  1
                 }
 126  
                 
 127  
                 public void update(int keys, int width, int height, float time_delta) {
 128  221
                         if (x <= 0 || x  + w >= width) {
 129  1
                                 speedx *= -1;
 130  
                         }
 131  
                         
 132  221
                         if (y <= 0 || y + h >= height) {
 133  0
                                 speedy *= -1;
 134  
                         }
 135  
                         
 136  221
                         x += speedx * time_delta;
 137  221
                         y += speedy * time_delta;
 138  221
                 }
 139  
         }
 140  
 }

Legend:
Instrumented line CCN: Cyclomatic Complexity
Covered line NCSS: Non-Commenting Source Statement
Uncovered line JVDC: JaVaDoc Comment