~mitya57/indicator-sound/lp1502480

« back to all changes in this revision

Viewing changes to tests/integration/test-indicator.cpp

  • Committer: CI Train Bot
  • Author(s): Xavi Garcia Mena
  • Date: 2016-03-07 10:13:52 UTC
  • mfrom: (529.1.11 last-runnin-player-charles)
  • Revision ID: ci-train-bot@canonical.com-20160307101352-jg9eqeccolp2rcfs
Add changes to show up the microphone controls when an external microphone is detected.
Approved by: PS Jenkins bot, Charles Kerr

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
{
33
33
};
34
34
 
 
35
TEST_F(TestIndicator, PhoneTestExternalMicInOut)
 
36
{
 
37
    double INITIAL_VOLUME = 0.0;
 
38
 
 
39
    ASSERT_NO_THROW(startAccountsService());
 
40
    EXPECT_TRUE(clearGSettingsPlayers());
 
41
    ASSERT_NO_THROW(startPulsePhone());
 
42
 
 
43
    // initialize volumes in pulseaudio
 
44
    EXPECT_TRUE(setStreamRestoreVolume("alert", INITIAL_VOLUME));
 
45
 
 
46
    // start now the indicator, so it picks the new volumes
 
47
    ASSERT_NO_THROW(startIndicator());
 
48
 
 
49
    EXPECT_MATCHRESULT(mh::MenuMatcher(phoneParameters())
 
50
        .item(mh::MenuItemMatcher()
 
51
            .action("indicator.root")
 
52
            .string_attribute("x-canonical-type", "com.canonical.indicator.root")
 
53
            .string_attribute("x-canonical-scroll-action", "indicator.scroll")
 
54
            .string_attribute("x-canonical-secondary-action", "indicator.mute")
 
55
            .string_attribute("submenu-action", "indicator.indicator-shown")
 
56
            .mode(mh::MenuItemMatcher::Mode::all)
 
57
            .submenu()
 
58
            .item(mh::MenuItemMatcher()
 
59
                .section()
 
60
                .item(silentModeSwitch(false))
 
61
                .item(volumeSlider(INITIAL_VOLUME, "Volume"))
 
62
            )
 
63
            .item(mh::MenuItemMatcher()
 
64
                .label("Sound Settings…")
 
65
                .action("indicator.phone-settings")
 
66
            )
 
67
        ).match());
 
68
 
 
69
    EXPECT_TRUE(plugExternalMic(true));
 
70
 
 
71
    // check that we have the mic slider now.
 
72
    EXPECT_MATCHRESULT(mh::MenuMatcher(phoneParameters())
 
73
        .item(mh::MenuItemMatcher()
 
74
            .action("indicator.root")
 
75
            .string_attribute("x-canonical-type", "com.canonical.indicator.root")
 
76
            .string_attribute("x-canonical-scroll-action", "indicator.scroll")
 
77
            .string_attribute("x-canonical-secondary-action", "indicator.mute")
 
78
            .string_attribute("submenu-action", "indicator.indicator-shown")
 
79
            .mode(mh::MenuItemMatcher::Mode::all)
 
80
            .submenu()
 
81
            .item(mh::MenuItemMatcher()
 
82
                .section()
 
83
                .item(silentModeSwitch(false))
 
84
                .item(volumeSlider(INITIAL_VOLUME, "Volume"))
 
85
                .item(micSlider(1.0, "Microphone Volume"))
 
86
            )
 
87
            .item(mh::MenuItemMatcher()
 
88
                .label("Sound Settings…")
 
89
                .action("indicator.phone-settings")
 
90
            )
 
91
        ).match());
 
92
 
 
93
 
 
94
    // unplug the external mic
 
95
    EXPECT_TRUE(plugExternalMic(false));
 
96
 
 
97
    // and check that there's no mic slider
 
98
    EXPECT_MATCHRESULT(mh::MenuMatcher(phoneParameters())
 
99
        .item(mh::MenuItemMatcher()
 
100
            .action("indicator.root")
 
101
            .string_attribute("x-canonical-type", "com.canonical.indicator.root")
 
102
            .string_attribute("x-canonical-scroll-action", "indicator.scroll")
 
103
            .string_attribute("x-canonical-secondary-action", "indicator.mute")
 
104
            .string_attribute("submenu-action", "indicator.indicator-shown")
 
105
            .mode(mh::MenuItemMatcher::Mode::all)
 
106
            .submenu()
 
107
            .item(mh::MenuItemMatcher()
 
108
                .section()
 
109
                .item(silentModeSwitch(false))
 
110
                .item(volumeSlider(INITIAL_VOLUME, "Volume"))
 
111
            )
 
112
            .item(mh::MenuItemMatcher()
 
113
                .label("Sound Settings…")
 
114
                .action("indicator.phone-settings")
 
115
            )
 
116
        ).match());
 
117
}
 
118
 
 
119
TEST_F(TestIndicator, DesktopTestExternalMicInOut)
 
120
{
 
121
    double INITIAL_VOLUME = 0.0;
 
122
 
 
123
    ASSERT_NO_THROW(startAccountsService());
 
124
    EXPECT_TRUE(clearGSettingsPlayers());
 
125
    ASSERT_NO_THROW(startPulseDesktop());
 
126
 
 
127
    // initialize volumes in pulseaudio
 
128
    EXPECT_FALSE(setStreamRestoreVolume("alert", INITIAL_VOLUME));
 
129
    EXPECT_TRUE(setSinkVolume(INITIAL_VOLUME));
 
130
 
 
131
    // start now the indicator, so it picks the new volumes
 
132
    ASSERT_NO_THROW(startIndicator());
 
133
 
 
134
    EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
 
135
        .item(mh::MenuItemMatcher()
 
136
            .action("indicator.root")
 
137
            .string_attribute("x-canonical-type", "com.canonical.indicator.root")
 
138
            .string_attribute("x-canonical-secondary-action", "indicator.mute")
 
139
            .mode(mh::MenuItemMatcher::Mode::all)
 
140
            .submenu()
 
141
            .item(mh::MenuItemMatcher()
 
142
                .section()
 
143
                .item(mh::MenuItemMatcher().checkbox()
 
144
                    .label("Mute")
 
145
                )
 
146
                .item(volumeSlider(INITIAL_VOLUME, "Volume"))
 
147
            )
 
148
            .item(mh::MenuItemMatcher()
 
149
                            .label("Sound Settings…")
 
150
             )
 
151
        ).match());
 
152
 
 
153
    EXPECT_TRUE(plugExternalMic(true));
 
154
 
 
155
    EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
 
156
        .item(mh::MenuItemMatcher()
 
157
            .action("indicator.root")
 
158
            .string_attribute("x-canonical-type", "com.canonical.indicator.root")
 
159
            .string_attribute("x-canonical-secondary-action", "indicator.mute")
 
160
            .mode(mh::MenuItemMatcher::Mode::all)
 
161
            .submenu()
 
162
            .item(mh::MenuItemMatcher()
 
163
                .section()
 
164
                .item(mh::MenuItemMatcher().checkbox()
 
165
                    .label("Mute")
 
166
                )
 
167
                .item(volumeSlider(INITIAL_VOLUME, "Volume"))
 
168
                .item(micSlider(1.0, "Microphone Volume"))
 
169
            )
 
170
            .item(mh::MenuItemMatcher()
 
171
                            .label("Sound Settings…")
 
172
             )
 
173
        ).match());
 
174
 
 
175
    EXPECT_TRUE(plugExternalMic(false));
 
176
 
 
177
    EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
 
178
           .item(mh::MenuItemMatcher()
 
179
               .action("indicator.root")
 
180
               .string_attribute("x-canonical-type", "com.canonical.indicator.root")
 
181
               .string_attribute("x-canonical-secondary-action", "indicator.mute")
 
182
               .mode(mh::MenuItemMatcher::Mode::all)
 
183
               .submenu()
 
184
               .item(mh::MenuItemMatcher()
 
185
                   .section()
 
186
                   .item(mh::MenuItemMatcher().checkbox()
 
187
                       .label("Mute")
 
188
                   )
 
189
                   .item(volumeSlider(INITIAL_VOLUME, "Volume"))
 
190
               )
 
191
               .item(mh::MenuItemMatcher()
 
192
                               .label("Sound Settings…")
 
193
                )
 
194
           ).match());
 
195
}
 
196
 
35
197
TEST_F(TestIndicator, DISABLED_PhoneChangeRoleVolume)
36
198
{
37
199
    double INITIAL_VOLUME = 0.0;