~mixxxdevelopers/mixxx/engine-control-refactor

« back to all changes in this revision

Viewing changes to mixxx/src/test/portmidienumeratortest.cpp

  • Committer: RJ Ryan
  • Date: 2013-06-04 00:41:29 UTC
  • mfrom: (2890.22.101 mixxx)
  • Revision ID: rryan@mixxx.org-20130604004129-8jjxkicsb3givu4a
MergingĀ fromĀ lp:mixxx.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <gtest/gtest.h>
 
2
#include <QtDebug>
 
3
 
 
4
#include "controllers/midi/portmidienumerator.h"
 
5
 
 
6
class PortMidiEnumeratorTest : public testing::Test {
 
7
  protected:
 
8
    virtual void SetUp() {
 
9
    }
 
10
 
 
11
    virtual void TearDown() {
 
12
    }
 
13
};
 
14
 
 
15
TEST_F(PortMidiEnumeratorTest, InputOutputPortsLinked) {
 
16
    // Identical device names should link.
 
17
    ASSERT_TRUE(shouldLinkInputToOutput(
 
18
        "Vestax VCI-100",
 
19
        "Vestax VCI-100"));
 
20
 
 
21
    // Different device names should not link.
 
22
    ASSERT_FALSE(shouldLinkInputToOutput(
 
23
        "Vestax VCI-100",
 
24
        "Vestax VCI-300"));
 
25
 
 
26
    // Ports with From or To in them that are otherwise equal should link.
 
27
    ASSERT_TRUE(shouldLinkInputToOutput(
 
28
        "From: Vestax VCI-100",
 
29
        "To: Vestax VCI-100"));
 
30
 
 
31
    // Ports with From or To in them that are otherwise equal should link. Case
 
32
    // does not matter.
 
33
    ASSERT_TRUE(shouldLinkInputToOutput(
 
34
        "frOm: Vestax VCI-100",
 
35
        "tO: Vestax VCI-100"));
 
36
 
 
37
    // Ports that match the pattern "$DEVICE MIDI $INSTANCE ..." should link.
 
38
 
 
39
    ASSERT_TRUE(shouldLinkInputToOutput(
 
40
        "Vestax VCI-100 MIDI 1",
 
41
        "Vestax VCI-100 MIDI 1"));
 
42
 
 
43
    // Stuff after $INSTANCE doesn't matter.
 
44
    ASSERT_TRUE(shouldLinkInputToOutput(
 
45
        "Vestax VCI-100 MIDI 1 OtherJunk",
 
46
        "Vestax VCI-100 MIDI 1 123 Doesn't Matter"));
 
47
 
 
48
    // Name is case-insensitive.
 
49
    ASSERT_TRUE(shouldLinkInputToOutput(
 
50
        "Vestax VCI-100 MIDI 1 OtherJunk",
 
51
        "VesTaX VCI-100 MIDI 1 123 Doesn't Matter"));
 
52
 
 
53
    // Different $INSTANCE matters.
 
54
    ASSERT_FALSE(shouldLinkInputToOutput(
 
55
        "Vestax VCI-100 MIDI 1 OtherJunk",
 
56
        "Vestax VCI-100 MIDI 2 123 Doesn't Matter"));
 
57
 
 
58
    // Different $INSTANCE with no trailing stuff matters.
 
59
    ASSERT_FALSE(shouldLinkInputToOutput(
 
60
        "Vestax VCI-100 MIDI 1",
 
61
        "Vestax VCI-100 MIDI 12"));
 
62
 
 
63
    // Extra stuff only on one doesn't matter.
 
64
    ASSERT_TRUE(shouldLinkInputToOutput(
 
65
        "Vestax VCI-100 MIDI 12",
 
66
        "Vestax VCI-100 MIDI 12 123 Something Else"));
 
67
 
 
68
    // Dangling numerals after the device name but before MIDI are fine.
 
69
    ASSERT_TRUE(shouldLinkInputToOutput(
 
70
        "Vestax VCI-100 2 MIDI 12",
 
71
        "Vestax VCI-100 2 MIDI 12 123 Something Else"));
 
72
 
 
73
    // Different $DEVICE matters.
 
74
    ASSERT_FALSE(shouldLinkInputToOutput(
 
75
        "Vestax VCI-100 MIDI 1",
 
76
        "Vestax VCI-300 MIDI 1"));
 
77
 
 
78
    // Non-numeral extra stuff following a lone numeral after the device name
 
79
    // doesn't matter.
 
80
    ASSERT_TRUE(shouldLinkInputToOutput(
 
81
        "nanoKONTROL2 1 CTRL",
 
82
        "nanoKONTROL2 1 SLIDER/KNOB"));
 
83
 
 
84
    // Extra stuff with a numeral following a lone numeral after the device name
 
85
    // doesn't get linked.
 
86
    ASSERT_FALSE(shouldLinkInputToOutput(
 
87
        "nanoKONTROL2 1 1 CTRL",
 
88
        "nanoKONTROL2 1 SLIDER/KNOB"));
 
89
 
 
90
    // If the device name has a numeral dangling off of it we should not get
 
91
    // confused by that.
 
92
    ASSERT_FALSE(shouldLinkInputToOutput(
 
93
        "nanoKONTROL 2 1 CTRL",
 
94
        "nanoKONTROL 2 3 SLIDER/KNOB"));
 
95
}