tmf: Fix GTK bug when setting top item after changing tree font
[deliverable/tracecompass.git] / pcap / org.eclipse.tracecompass.pcap.core.tests / src / org / eclipse / tracecompass / pcap / core / tests / protocol / ProtocolTest.java
CommitLineData
a1d21447
VP
1/*******************************************************************************
2 * Copyright (c) 2014 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 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
12
71f2817f 13package org.eclipse.tracecompass.pcap.core.tests.protocol;
a1d21447
VP
14
15import static org.junit.Assert.assertEquals;
e20e3d49 16import static org.junit.Assert.assertNotNull;
a1d21447
VP
17import static org.junit.Assert.fail;
18
19import java.util.ArrayList;
e20e3d49 20import java.util.Collection;
a1d21447
VP
21import java.util.List;
22
71f2817f 23import org.eclipse.tracecompass.internal.pcap.core.protocol.PcapProtocol;
a1d21447
VP
24import org.junit.Test;
25
26/**
27 * JUnit Class that tests whether protocol operation are happening without
28 * error.
29 *
30 * @author Vincent Perot
31 */
32public class ProtocolTest {
33
34 /**
35 * Test that verify if the protocol attributes are as expected.
36 */
37 @Test
38 public void TestProtocolAttributes() {
c88feda9
AM
39 assertEquals(PcapProtocol.PCAP.getName(), "Packet Capture");
40 assertEquals(PcapProtocol.PCAP.getShortName(), "pcap");
e20e3d49 41 assertEquals(PcapProtocol.PCAP.getLayer(), PcapProtocol.Layer.LAYER_0);
a1d21447
VP
42 }
43
44 /**
45 * Test that verify if the protocol getter methods are working properly.
46 */
47 @Test
48 public void TestgetProtocols() {
c88feda9 49 List<PcapProtocol> manualListLayer = new ArrayList<>();
e20e3d49
AM
50 for (PcapProtocol.Layer layer : PcapProtocol.Layer.values()) {
51 assertNotNull(layer);
52 Collection<PcapProtocol> listLayer = PcapProtocol.getProtocolsOnLayer(layer);
a1d21447
VP
53
54 manualListLayer.clear();
e20e3d49
AM
55 switch (layer) {
56 case LAYER_0:
c88feda9 57 manualListLayer.add(PcapProtocol.PCAP);
a1d21447 58 break;
e20e3d49 59 case LAYER_1:
a1d21447 60 break;
e20e3d49 61 case LAYER_2:
c88feda9 62 manualListLayer.add(PcapProtocol.ETHERNET_II);
a1d21447 63 break;
e20e3d49 64 case LAYER_3:
c88feda9 65 manualListLayer.add(PcapProtocol.IPV4);
a1d21447 66 break;
e20e3d49 67 case LAYER_4:
c88feda9
AM
68 manualListLayer.add(PcapProtocol.TCP);
69 manualListLayer.add(PcapProtocol.UDP);
a1d21447 70 break;
e20e3d49 71 case LAYER_5:
a1d21447 72 break;
e20e3d49 73 case LAYER_6:
a1d21447 74 break;
e20e3d49 75 case LAYER_7:
c88feda9 76 manualListLayer.add(PcapProtocol.UNKNOWN);
a1d21447
VP
77 break;
78 default:
79 fail("Illegal layer value!");
80 }
81 assertEquals(manualListLayer, listLayer);
82 }
a1d21447
VP
83 }
84
85}
This page took 0.077539 seconds and 5 git commands to generate.