Merge lp:~3v1n0/unity/launcher-controller-tests-fix into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: no longer in the source branch.
Merged at revision: 2895
Proposed branch: lp:~3v1n0/unity/launcher-controller-tests-fix
Merge into: lp:unity
Diff against target: 117 lines (+25/-13)
1 file modified
tests/test_launcher_controller.cpp (+25/-13)
To merge this branch: bzr merge lp:~3v1n0/unity/launcher-controller-tests-fix
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+134202@code.launchpad.net

Commit message

TestLauncherController: fix some random failures

Description of the change

Fixed some random LauncherController tests failures, also needs lp:~3v1n0/bamf/libbamf-dont-duplicate-apps.

To post a comment you must log in.
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Looks good, doesn't break anything and it seems to help some unity unit tests! +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_launcher_controller.cpp'
2--- tests/test_launcher_controller.cpp 2012-11-06 18:19:09 +0000
3+++ tests/test_launcher_controller.cpp 2012-11-13 20:58:21 +0000
4@@ -222,7 +222,7 @@
5 {
6 auto const& model = Impl()->model_;
7 auto icon = std::find_if(model->begin(), model->end(),
8- [&path](AbstractLauncherIcon::Ptr const& i) { return ( i->DesktopFile() == path); });
9+ [&path](AbstractLauncherIcon::Ptr const& i) { return (i->DesktopFile() == path); });
10
11 if (icon != model->end())
12 return *icon;
13@@ -287,13 +287,18 @@
14 for (auto const& fav_uri : favorite_store.GetFavorites())
15 {
16 auto model_icon_it = std::find_if(lc.Impl()->model_->begin(), lc.Impl()->model_->end(),
17- [&fav_uri](AbstractLauncherIcon::Ptr const& i) { return (i->RemoteUri() == fav_uri); });
18- auto const& icon_it = *model_icon_it;
19+ [&fav_uri](AbstractLauncherIcon::Ptr const& i) { return (i->RemoteUri() == fav_uri); });
20+ bool valid_iter = (model_icon_it != lc.Impl()->model_->end());
21
22 if (fav_uri == places::APPS_URI || fav_uri == places::DEVICES_URI)
23- ASSERT_FALSE(icon_it.IsValid());
24+ {
25+ ASSERT_FALSE(valid_iter);
26+ }
27 else
28- ASSERT_TRUE(icon_it.IsValid());
29+ {
30+ ASSERT_TRUE(valid_iter);
31+ ASSERT_TRUE(model_icon_it->IsValid());
32+ }
33 }
34 }
35
36@@ -711,8 +716,10 @@
37 if (!BAMF_IS_APPLICATION(l->data))
38 continue;
39
40+ if (bamf_view_is_sticky(BAMF_VIEW(l->data)))
41+ continue;
42+
43 BamfApplication* app = BAMF_APPLICATION(l->data);
44-
45 ASSERT_NE(g_object_get_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen")), nullptr);
46
47 auto desktop = bamf_application_get_desktop_file(app);
48@@ -755,9 +762,9 @@
49 FavoriteStore::URI_PREFIX_APP + app::SW_CENTER,
50 places::DEVICES_URI,
51 FavoriteStore::URI_PREFIX_APP + app::UPDATE_MANAGER });
52- std::shared_ptr<GList> apps(bamf_matcher_get_applications(lc.Impl()->matcher_), g_list_free);
53 lc.Impl()->SetupIcons();
54 lc.DisconnectSignals();
55+ std::shared_ptr<GList> apps(bamf_matcher_get_applications(lc.Impl()->matcher_), g_list_free);
56
57 auto fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::UBUNTU_ONE);
58 EXPECT_EQ(model->IconIndex(fav), icon_index);
59@@ -771,12 +778,14 @@
60 fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::UPDATE_MANAGER);
61 EXPECT_EQ(model->IconIndex(fav), ++icon_index);
62
63-
64 for (GList *l = apps.get(); l; l = l->next)
65 {
66 if (!BAMF_IS_APPLICATION(l->data))
67 continue;
68
69+ if (bamf_view_is_sticky(BAMF_VIEW(l->data)))
70+ continue;
71+
72 auto desktop = bamf_application_get_desktop_file(BAMF_APPLICATION(l->data));
73 std::string path(desktop ? desktop : "");
74 ++icon_index;
75@@ -784,9 +793,7 @@
76 if (path.empty())
77 continue;
78
79- auto const& icon = lc.GetIconByDesktop(path);
80-
81- ASSERT_TRUE(icon.IsValid());
82+ auto icon = lc.GetIconByDesktop(path);
83 ASSERT_EQ(model->IconIndex(icon), icon_index);
84 }
85
86@@ -801,9 +808,9 @@
87
88 favorite_store.AddFavorite(places::APPS_URI, -1);
89 favorite_store.AddFavorite(places::DEVICES_URI, -1);
90- std::shared_ptr<GList> apps(bamf_matcher_get_applications(lc.Impl()->matcher_), g_list_free);
91 lc.Impl()->SetupIcons();
92 lc.DisconnectSignals();
93+ std::shared_ptr<GList> apps(bamf_matcher_get_applications(lc.Impl()->matcher_), g_list_free);
94
95 favorite_store.SetFavorites({ places::DEVICES_URI,
96 FavoriteStore::URI_PREFIX_APP + app::SW_CENTER,
97@@ -825,6 +832,9 @@
98 if (!BAMF_IS_APPLICATION(l->data))
99 continue;
100
101+ if (bamf_view_is_sticky(BAMF_VIEW(l->data)))
102+ continue;
103+
104 auto desktop = bamf_application_get_desktop_file(BAMF_APPLICATION(l->data));
105 std::string path(desktop ? desktop : "");
106 ++icon_index;
107@@ -1516,7 +1526,9 @@
108 {
109 UBusManager manager;
110 std::string last_selection_change;
111- manager.RegisterInterest(UBUS_LAUNCHER_SELECTION_CHANGED, [&] (GVariant *data) { last_selection_change = g_variant_get_string(data, 0); });
112+ manager.RegisterInterest(UBUS_LAUNCHER_SELECTION_CHANGED, [&] (GVariant *data) {
113+ last_selection_change = g_variant_get_string(data, 0);
114+ });
115
116 lc.KeyNavGrab();
117 ProcessUBusMessages();