1 /*******************************************************************************
2 * Copyright (c) 2015 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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.tests
.filter
;
15 import static org
.junit
.Assert
.assertArrayEquals
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertFalse
;
18 import static org
.junit
.Assert
.assertTrue
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventField
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEvent
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEventField
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterNode
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterRootNode
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfNanoTimestamp
;
26 import org
.junit
.Before
;
27 import org
.junit
.Test
;
30 * Test suite for the {@link TmfFilterRootNode} class.
32 * @author Patrick Tasse
34 @SuppressWarnings("javadoc")
35 public class TmfFilterRootNodeTest
extends TmfFilterTreeNodeTest
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 private ITmfEventField fContent
= new TmfEventField(ITmfEventField
.ROOT_FIELD_ID
, null, null);
42 private TmfEvent fEvent
= new TmfEvent(TRACE
, 0, new TmfNanoTimestamp(1), EVENT_TYPE
, fContent
);
43 private TmfFilterRootNode fFilter
;
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
50 public void createFilter() {
51 fFilter
= new TmfFilterRootNode();
52 fFilterNode
= fFilter
;
56 public void testMatches() {
57 fFilter
.addChild(TRUE_NODE
);
58 fFilter
.addChild(TRUE_NODE
);
59 assertTrue(fFilter
.matches(fEvent
));
61 fFilter
.replaceChild(0, FALSE_NODE
);
62 assertFalse(fFilter
.matches(fEvent
));
66 public void testGetName() {
67 assertEquals("getName()", "ROOT", fFilter
.getNodeName());
71 public void testGetValidChildren() {
72 assertArrayEquals("getValidChildren()", new String
[] { TmfFilterNode
.NODE_NAME
}, fFilter
.getValidChildren().toArray());