1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alexandre Montplaisir - Port to JUnit4
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.ui
.tests
.statistics
;
15 import static org
.junit
.Assert
.assertEquals
;
17 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.statistics
.model
.TmfStatisticsValues
;
18 import org
.junit
.Test
;
21 * TmfStatistics Test Cases.
23 public class TmfStatisticsTest
{
25 private TmfStatisticsValues stats
= new TmfStatisticsValues();
28 * Test the initial state of the counters
31 public void testInitialState() {
32 assertEquals(0, stats
.getTotal());
33 assertEquals(0, stats
.getPartial());
37 * Test incrementing the total counter by an amount
40 public void testSetValue() {
43 /* Set the Global counter */
44 stats
.setValue(true, i
);
45 assertEquals(i
, stats
.getTotal());
46 // Try to assign a negative number. Should do nothing.
47 stats
.setValue(true, -10);
48 assertEquals(i
, stats
.getTotal());
49 // Checks if the partial counter was affected
50 assertEquals(0, stats
.getPartial());
52 /* Set the time range counter */
53 stats
.resetTotalCount();
54 stats
.setValue(false, i
);
55 assertEquals(i
, stats
.getPartial());
56 // Try to assign a negative number. Should do nothing.
57 stats
.setValue(false, -10);
58 assertEquals(i
, stats
.getPartial());
59 // Checks if the total counter was affected
60 assertEquals(0, stats
.getTotal());
64 * Test of the reset for the total counter
67 public void testResetTotal() {
68 stats
.setValue(true, 123);
69 assertEquals(123, stats
.getTotal());
71 stats
.resetTotalCount();
72 assertEquals(0, stats
.getTotal());
74 // test when already at 0
75 stats
.resetTotalCount();
76 assertEquals(0, stats
.getTotal());
80 * Test of the reset for the partial counter
83 public void testResetPartial() {
84 stats
.setValue(false, 456);
85 assertEquals(456, stats
.getPartial());
87 stats
.resetPartialCount();
88 assertEquals(0, stats
.getPartial());
90 // test when already at 0
91 stats
.resetPartialCount();
92 assertEquals(0, stats
.getPartial());