~alan-griffiths/miral/debug

« back to all changes in this revision

Viewing changes to miral-qt/tests/mirserver/ArgvHelper/argvHelper_test.cpp

  • Committer: Gerry Boland
  • Date: 2016-06-01 22:06:51 UTC
  • mto: This revision was merged to the branch mainline in revision 178.
  • Revision ID: gerry.boland@canonical.com-20160601220651-ge508tffql4e7u7c
Import QtMir code into miral-qt subdirectory. Disabled by default, use -DMIRAL_ENABLE_QT=1 to build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it under
 
5
 * the terms of the GNU Lesser General Public License version 3, as published by
 
6
 * the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
9
 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
 
10
 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#include <gtest/gtest.h>
 
18
 
 
19
#include <argvHelper.h>
 
20
 
 
21
using namespace qtmir;
 
22
 
 
23
TEST(ArgvHelperTest, StripsCorrectly)
 
24
{
 
25
    int argc = 5;
 
26
    const char *argv[6] = { "/usr/bin/unity8", "-fullscreen", "--debug",
 
27
                            "--platform-input-lib=/path/to/lib.so", "-testability", nullptr };
 
28
 
 
29
    const int filteredArgc = 2;
 
30
    const char *filteredArgv[3] = { "-fullscreen", "-testability", nullptr };
 
31
 
 
32
    editArgvToMatch(argc, const_cast<char**>(argv), filteredArgc, filteredArgv);
 
33
 
 
34
    EXPECT_EQ(argc, 3);
 
35
    EXPECT_EQ(argv[0], "/usr/bin/unity8");
 
36
    EXPECT_EQ(argv[1], "-fullscreen");
 
37
    EXPECT_EQ(argv[2], "-testability");
 
38
    EXPECT_EQ(argv[3], nullptr);
 
39
}
 
40
 
 
41
TEST(ArgvHelperTest, NothingToStrip)
 
42
{
 
43
    int argc = 4;
 
44
    const char *argv[5] = { "/usr/bin/unity8", "-fullscreen", "--multisample", "-testability", nullptr };
 
45
 
 
46
    const int filteredArgc = 3;
 
47
    const char *filteredArgv[4] = { "-fullscreen", "-testability", "--multisample", nullptr };
 
48
 
 
49
    editArgvToMatch(argc, const_cast<char**>(argv), filteredArgc, filteredArgv);
 
50
 
 
51
    EXPECT_EQ(argc, 4);
 
52
    EXPECT_EQ(argv[0], "/usr/bin/unity8");
 
53
    EXPECT_EQ(argv[1], "-fullscreen");
 
54
    EXPECT_EQ(argv[2], "-testability");
 
55
    EXPECT_EQ(argv[3], "--multisample");
 
56
    EXPECT_EQ(argv[4], nullptr);
 
57
}
 
58
 
 
59
TEST(ArgvHelperTest, NothingToDo)
 
60
{
 
61
    int argc = 1;
 
62
    const char *argv[2] = { "/usr/bin/unity8", nullptr };
 
63
 
 
64
    const int filteredArgc = 0;
 
65
    const char *filteredArgv[1] = { nullptr };
 
66
 
 
67
    editArgvToMatch(argc, const_cast<char**>(argv), filteredArgc, filteredArgv);
 
68
 
 
69
    EXPECT_EQ(argc, 1);
 
70
    EXPECT_EQ(argv[0], "/usr/bin/unity8");
 
71
    EXPECT_EQ(argv[1], nullptr);
 
72
}