~timo-jyrinki/ubuntu/trusty/maliit-framework/fix_qt52

« back to all changes in this revision

Viewing changes to tests/ut_mimserveroptions/ut_mimserveroptions.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Sergio Schvezov, Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mfrom: (1.1.2) (1.2.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130723194704-1lsy1kmlda069cea
Tags: 0.99.0+git20130615+97e8335-0ubuntu1
[ Sergio Schvezov ]
* New build from HEAD 97e8335.
* Packaging import from lp:phablet-extras/maliit-framework.

[ Ricardo Salveti de Araujo ]
* debian/control: adding vcs and fixing dependencies
* General package cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
Q_DECLARE_METATYPE(Args);
31
31
Q_DECLARE_METATYPE(MImServerCommonOptions);
32
 
Q_DECLARE_METATYPE(MImServerXOptions);
33
32
 
34
33
namespace {
35
34
    Args Help              = { 2, { "", "-help" } };
39
38
    Args ProgramNameOnly   = { 1, { "name" } };
40
39
    Args BypassedParameter = { 1, { "name", "-help" } };
41
40
 
42
 
    Args XOptions1 = { 2, { "", "-manual-redirection" } };
43
 
    Args XOptions2 = { 3, { "", "-manual-redirection", "-bypass-wm-hint" } };
44
 
 
45
 
    Args XOptions3 = { 4, { "", "-manual-redirection", "-bypass-wm-hint",
46
 
                            "-use-self-composition"} };
47
 
 
48
 
    Args XOptions4 = { 5, { "", "-manual-redirection", "-bypass-wm-hint",
49
 
                            "-use-self-composition", "-unconditional-show"} };
50
 
 
51
 
    Args Ignored = { 16, { "", "-style", "STYLE", "-session", "SESSION",
 
41
    Args Ignored = { 15, { "", "-style", "STYLE", "-session", "SESSION",
52
42
                           "-graphicssystem", "GRAPHICSSYSTEM",
53
43
                          "-testability", "TESTABILITY", "-qdevel", "-reverse",
54
44
                          "-stylesheet", "-widgetcount", "-qdebug",
55
 
                          "-software", "-remote-theme" } };
 
45
                          "-software" } };
56
46
 
57
47
    bool operator==(const MImServerCommonOptions &x,
58
48
                    const MImServerCommonOptions &y)
59
49
    {
60
50
        return (x.showHelp == y.showHelp);
61
51
    }
62
 
 
63
 
    bool operator==(const MImServerXOptions &x,
64
 
                    const MImServerXOptions &y)
65
 
    {
66
 
        return x.bypassWMHint == y.bypassWMHint
67
 
               && x.manualRedirection == y.manualRedirection
68
 
               && x.selfComposited == y.selfComposited
69
 
               && x.unconditionalShow == y.unconditionalShow;
70
 
    }
71
52
}
72
53
 
73
54
 
86
67
void Ut_MImServerOptions::cleanup()
87
68
{
88
69
    commonOptions = MImServerCommonOptions();
89
 
    xOptions = MImServerXOptions();
90
70
}
91
71
 
92
72
void Ut_MImServerOptions::testCommonOptions_data()
93
73
{
94
74
    QTest::addColumn<Args>("args");
95
75
    QTest::addColumn<MImServerCommonOptions>("expectedCommonOptions");
96
 
    QTest::addColumn<MImServerXOptions>("expectedXOptions");
97
76
    QTest::addColumn<bool>("expectedRecognition");
98
77
 
99
78
    MImServerCommonOptions helpEnabled;
100
79
    helpEnabled.showHelp = true;
101
80
 
102
 
    MImServerXOptions allXDisabled;
103
 
 
104
 
    QTest::newRow("help") << Help << helpEnabled << allXDisabled << true;
105
 
 
106
 
    QTest::newRow("help+invalid") << HelpPlusInvalid << helpEnabled << allXDisabled << false;
 
81
    QTest::newRow("help") << Help << helpEnabled << true;
 
82
 
 
83
    QTest::newRow("help+invalid") << HelpPlusInvalid << helpEnabled << false;
107
84
 
108
85
    MImServerCommonOptions helpDisabled;
109
86
 
110
 
    QTest::newRow("invalid") << Invalid << helpDisabled << allXDisabled << false;
 
87
    QTest::newRow("invalid") << Invalid << helpDisabled << false;
111
88
 
112
89
    // at least we should not crash with such parameters
113
 
    QTest::newRow("nothing") << Nothing << helpDisabled << allXDisabled << true;
114
 
 
115
 
    QTest::newRow("bypassed parameter") << BypassedParameter << helpDisabled << allXDisabled << true;
116
 
 
117
 
    QTest::newRow("program name only") << ProgramNameOnly << helpDisabled << allXDisabled << true;
118
 
 
119
 
    QTest::newRow("ignored") << Ignored << helpDisabled << allXDisabled << true;
120
 
 
121
 
    MImServerXOptions xOptions(allXDisabled);
122
 
 
123
 
    xOptions.manualRedirection = true;
124
 
    QTest::newRow("x options 1") << XOptions1 << helpDisabled << xOptions << true;
125
 
 
126
 
    xOptions.bypassWMHint = true;
127
 
    QTest::newRow("x options 2") << XOptions2 << helpDisabled << xOptions << true;
128
 
 
129
 
    xOptions.selfComposited = true;
130
 
    QTest::newRow("x options 3") << XOptions3 << helpDisabled << xOptions << true;
131
 
 
132
 
    xOptions.unconditionalShow = true;
133
 
    QTest::newRow("x options 4") << XOptions4 << helpDisabled << xOptions << true;
 
90
    QTest::newRow("nothing") << Nothing << helpDisabled << true;
 
91
 
 
92
    QTest::newRow("bypassed parameter") << BypassedParameter << helpDisabled << true;
 
93
 
 
94
    QTest::newRow("program name only") << ProgramNameOnly << helpDisabled << true;
 
95
 
 
96
    QTest::newRow("ignored") << Ignored << helpDisabled << true;
134
97
}
135
98
 
136
99
void Ut_MImServerOptions::testCommonOptions()
137
100
{
138
101
    QFETCH(Args, args);
139
102
    QFETCH(MImServerCommonOptions, expectedCommonOptions);
140
 
    QFETCH(MImServerXOptions, expectedXOptions);
141
103
    QFETCH(bool, expectedRecognition);
142
104
 
143
105
    bool everythingRecognized = parseCommandLine(args.argc, args.argv);
144
106
 
145
107
    QCOMPARE(everythingRecognized, expectedRecognition);
146
108
    QCOMPARE(commonOptions, expectedCommonOptions);
147
 
    QCOMPARE(xOptions, expectedXOptions);
148
109
}
149
110
 
150
111
QTEST_MAIN(Ut_MImServerOptions)