Commit | Line | Data |
---|---|---|
ebc1e992 PT |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015 Ericsson | |
3 | * | |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Patrick Tasse - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.tracecompass.tmf.core.tests.filter; | |
14 | ||
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; | |
19 | ||
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; | |
28 | ||
29 | /** | |
30 | * Test suite for the {@link TmfFilterRootNode} class. | |
31 | * | |
32 | * @author Patrick Tasse | |
33 | */ | |
34 | @SuppressWarnings("javadoc") | |
35 | public class TmfFilterRootNodeTest extends TmfFilterTreeNodeTest { | |
36 | ||
37 | // ------------------------------------------------------------------------ | |
38 | // Variables | |
39 | // ------------------------------------------------------------------------ | |
40 | ||
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; | |
44 | ||
45 | // ------------------------------------------------------------------------ | |
46 | // Tests | |
47 | // ------------------------------------------------------------------------ | |
48 | ||
49 | @Before | |
50 | public void createFilter() { | |
51 | fFilter = new TmfFilterRootNode(); | |
52 | fFilterNode = fFilter; | |
53 | } | |
54 | ||
55 | @Test | |
56 | public void testMatches() { | |
57 | fFilter.addChild(TRUE_NODE); | |
58 | fFilter.addChild(TRUE_NODE); | |
59 | assertTrue(fFilter.matches(fEvent)); | |
60 | ||
61 | fFilter.replaceChild(0, FALSE_NODE); | |
62 | assertFalse(fFilter.matches(fEvent)); | |
63 | } | |
64 | ||
65 | @Test | |
66 | public void testGetName() { | |
67 | assertEquals("getName()", "ROOT", fFilter.getNodeName()); | |
68 | } | |
69 | ||
70 | @Test | |
71 | public void testGetValidChildren() { | |
72 | assertArrayEquals("getValidChildren()", new String[] { TmfFilterNode.NODE_NAME }, fFilter.getValidChildren().toArray()); | |
73 | } | |
74 | } |