1 /*******************************************************************************
2 * Copyright (c) 2011-2013 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 * Bernd Hufmann - Initial API and implementation
11 * Alexandre Montplaisir - Port to JUnit4
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.ui
.tests
.views
.uml2sd
.loader
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertFalse
;
18 import static org
.junit
.Assert
.assertNotNull
;
19 import static org
.junit
.Assert
.assertTrue
;
20 import static org
.junit
.Assert
.fail
;
22 import java
.util
.List
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalManager
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.dialogs
.FilterCriteria
;
26 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.dialogs
.FilterListDialog
;
27 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDAdvancedPagingProvider
;
28 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDPagingProvider
;
29 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.loader
.TmfUml2SDSyncLoader
;
30 import org
.junit
.AfterClass
;
31 import org
.junit
.BeforeClass
;
32 import org
.junit
.Test
;
35 * Test cases for Experiment handling.
37 * @author Bernd Hufmann
39 public class TmfUml2SDSyncLoaderExpTest
{
41 private static Uml2SDTestFacility fFacility
;
47 public static void setUpClass() {
48 fFacility
= Uml2SDTestFacility
.getInstance();
49 // create filter criteria (incl. save)
50 fFacility
.createFilterCriteria();
51 fFacility
.selectExperiment();
58 public static void tearDownClass() {
59 fFacility
.disposeExperiment();
66 * Verified Methods: loader.getTitleString()
69 * Expected result: Title, view name are set properly.
72 public void verifySetup() {
73 assertEquals("getTitleString", "Component Interactions", fFacility
.getLoader().getTitleString());
74 assertEquals("getPartName", "Sequence Diagram", fFacility
.getSdView().getPartName());
75 assertNotNull("getFrame", fFacility
.getSdView().getFrame());
77 fFacility
.disposeExperiment();
79 fFacility
.delay(IUml2SDTestConstants
.GUI_REFESH_DELAY
);
80 verifyPage(0, 0, false, false, 0);
84 * Verify cancellation of ongoing indexing.
86 * Verified Methods: loader.experimentSelected(), loader.experimentDisposed(), loader.nextPage()
87 * Expected result: No exceptions during cancellation and nextPage() operation.
89 * Note this test is not sufficient to verify the concurrent access of the loader attributes
90 * by multiple threads. Contention might happen but it's not guaranteed.
93 public void verifyCancel() {
94 for(int i
= 0; i
< 5; i
++) {
95 fFacility
.selectExperiment(false);
96 fFacility
.delay(IUml2SDTestConstants
.INITIAL_INDEX_DELAY
);
99 fFacility
.disposeExperiment();
100 fFacility
.getLoader().nextPage(); // to test out of bounce
101 // Note: To actually create an out of bound exception remove
102 // safety-checks in nextPage/moveToPage of loader class
103 } catch (Exception e
){
104 // No Exception expected
105 fail("exp.select/exp.dispose");
111 * Verify disposed experiment.
113 * Verified Methods: loader.nextPage(),
114 * loader.pagesCount(), loader.hasNextPage(), loader.hasPrevPage(),
115 * frame.syncMessagesCount, frame.lifeLinesCount
116 * Expected result: Page values and filter are reset.
118 * Note this test is not sufficient to verify the concurrent access of the loader attributes
119 * by multiple threads. Contention might happen but it's not guaranteed.
122 public void verifyDispose() {
123 verifyPage(0, 0, false, false, 0);
125 // verify that all enable filters are disabled after disposal
126 List
<FilterCriteria
> filter
= FilterListDialog
.getGlobalFilters();
128 for (FilterCriteria filterCriteria
: filter
) {
129 assertFalse("exp.dispose", filterCriteria
.isActive());
134 * Verify the disposal of the loader.
136 * Verified Methods: loader.dispose()
137 * Expected result: All providers are removed from SDView.
140 public void verifyLoaderDispose() {
141 fFacility
.getLoader().dispose();
142 assertTrue("loader.dispose", fFacility
.getSdView().getSDPagingProvider() == null);
143 assertTrue("loader.dispose", fFacility
.getSdView().getSDFindProvider() == null);
144 assertTrue("loader.dispose", fFacility
.getSdView().getSDFilterProvider() == null);
145 assertTrue("loader.dispose", fFacility
.getSdView().getExtendedFindProvider() == null);
146 assertTrue("loader.dispose", fFacility
.getSdView().getExtendedFilterProvider() == null);
148 // Set again loader as signal handler, which was removed by the the dispose above
149 TmfSignalManager
.register(fFacility
.getLoader());
155 * Verified Methods: loader.setViewer
156 * Expected result: Paging, find and filter provider are set
159 public void testSetViewer() {
160 fFacility
.getLoader().setViewer(fFacility
.getSdView());
161 ISDPagingProvider pagingProvider
= fFacility
.getSdView().getSDPagingProvider();
162 assertTrue("loader.setViewer", pagingProvider
!= null);
163 assertTrue("loader.setViewer", pagingProvider
instanceof ISDAdvancedPagingProvider
);
164 assertTrue("loader.setViewer", pagingProvider
instanceof TmfUml2SDSyncLoader
);
166 assertTrue("loader.setViewer", fFacility
.getSdView().getSDFindProvider() != null);
168 assertTrue("loader.setViewer", fFacility
.getSdView().getSDFilterProvider() != null);
170 // All other providers are not used.
171 assertTrue("loader.setViewer", fFacility
.getSdView().getExtendedFindProvider() == null);
172 assertTrue("loader.setViewer", fFacility
.getSdView().getExtendedFilterProvider() == null);
175 private static void verifyPage(int currentPage
, int numMsg
, boolean hasNext
,
176 boolean hasPrev
, int lifelineCount
) {
177 assertEquals("currentPage", currentPage
, fFacility
.getLoader().currentPage());
178 assertEquals("syncMessageCount, ", numMsg
, fFacility
.getSdView().getFrame().syncMessageCount());
180 assertTrue("hasNextpage", fFacility
.getLoader().hasNextPage());
182 assertFalse("hasNextPage", fFacility
.getLoader().hasNextPage());
185 assertTrue("hasPrevPage", fFacility
.getLoader().hasPrevPage());
187 assertFalse("hasPrevPage", fFacility
.getLoader().hasPrevPage());
189 assertEquals("lifeLinesCount", lifelineCount
, fFacility
.getSdView().getFrame().lifeLinesCount());