~xavi-garcia-mena/indicator-sound/icon-volume-zero

« back to all changes in this revision

Viewing changes to tests/notifications-test.cc

  • Committer: CI Train Bot
  • Author(s): Ted Gould
  • Date: 2015-02-27 22:36:17 UTC
  • mfrom: (480.3.3 lp1422745-menu-open)
  • Revision ID: ci-train-bot@canonical.com-20150227223617-07pj43jhcd1an7cg
Switch to an internal variable to track blocking notifications
Approved by: Charles Kerr, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
                        volume_control_set_volume(volumeControl.get(), vol);
147
147
                        g_object_unref(vol);
148
148
                }
 
149
 
 
150
                void setIndicatorShown (bool shown) {
 
151
                        auto bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
 
152
 
 
153
                        g_dbus_connection_call(bus,
 
154
                                g_dbus_connection_get_unique_name(bus),
 
155
                                "/com/canonical/indicator/sound",
 
156
                                "org.gtk.Actions",
 
157
                                "SetState",
 
158
                                g_variant_new("(sva{sv})", "indicator-shown", g_variant_new_boolean(shown), nullptr),
 
159
                                nullptr,
 
160
                                G_DBUS_CALL_FLAGS_NONE,
 
161
                                -1,
 
162
                                nullptr,
 
163
                                nullptr,
 
164
                                nullptr);
 
165
 
 
166
                        g_clear_object(&bus);
 
167
                }
149
168
};
150
169
 
151
170
TEST_F(NotificationsTest, BasicObject) {
357
376
        EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]);
358
377
}
359
378
 
 
379
TEST_F(NotificationsTest, MenuHide) {
 
380
        auto volumeControl = volumeControlMock();
 
381
        auto soundService = standardService(volumeControl, playerListMock());
 
382
 
 
383
        /* Set a volume */
 
384
        notifications->clearNotifications();
 
385
        setMockVolume(volumeControl, 0.50);
 
386
        loop(50);
 
387
        auto notev = notifications->getNotifications();
 
388
        EXPECT_EQ(1, notev.size());
 
389
 
 
390
        /* Set the indicator to shown, and set a new volume */
 
391
        notifications->clearNotifications();
 
392
        setIndicatorShown(true);
 
393
        loop(50);
 
394
        setMockVolume(volumeControl, 0.60);
 
395
        loop(50);
 
396
        notev = notifications->getNotifications();
 
397
        EXPECT_EQ(0, notev.size());
 
398
 
 
399
        /* Set the indicator to hidden, and set a new volume */
 
400
        notifications->clearNotifications();
 
401
        setIndicatorShown(false);
 
402
        loop(50);
 
403
        setMockVolume(volumeControl, 0.70);
 
404
        loop(50);
 
405
        notev = notifications->getNotifications();
 
406
        EXPECT_EQ(1, notev.size());
 
407
}
 
408
 
360
409
TEST_F(NotificationsTest, ExtendendVolumeNotification) {
361
410
        auto volumeControl = volumeControlMock();
362
411
        auto soundService = standardService(volumeControl, playerListMock());
397
446
        ASSERT_EQ(1, notev.size());
398
447
        EXPECT_GVARIANT_EQ("@i 100", notev[0].hints["value"]);
399
448
}
400