Merge lp:~unity-team/unity/y-sru1 into lp:unity/yakkety

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 4195
Proposed branch: lp:~unity-team/unity/y-sru1
Merge into: lp:unity/yakkety
Diff against target: 602 lines (+370/-41)
13 files modified
UnityCore/GnomeSessionManager.cpp (+59/-26)
UnityCore/GnomeSessionManagerImpl.h (+2/-0)
UnityCore/Variant.cpp (+30/-0)
UnityCore/Variant.h (+1/-0)
debian/changelog (+17/-0)
decorations/DecorationsForceQuitDialog.cpp (+4/-2)
launcher/FileManagerLauncherIcon.cpp (+30/-0)
launcher/FileManagerLauncherIcon.h (+8/-0)
launcher/StorageLauncherIcon.cpp (+7/-12)
lockscreen/LockScreenController.cpp (+1/-0)
tests/CMakeLists.txt (+1/-0)
tests/test_file_manager_launcher_icon.cpp (+202/-0)
tests/test_gnome_session_manager.cpp (+8/-1)
To merge this branch: bzr merge lp:~unity-team/unity/y-sru1
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+310650@code.launchpad.net

Commit message

Releasing SRU1 for yakkety

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1 Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'UnityCore/GnomeSessionManager.cpp'
--- UnityCore/GnomeSessionManager.cpp 2016-09-01 17:18:03 +0000
+++ UnityCore/GnomeSessionManager.cpp 2016-11-11 14:53:10 +0000
@@ -101,32 +101,37 @@
101 });101 });
102102
103 {103 {
104 const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID");104 std::string session_id = test_mode_ ? "id0" : glib::gchar_to_string(g_getenv("XDG_SESSION_ID"));
105105
106 login_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1",106 if (!session_id.empty())
107 "/org/freedesktop/login1/session/" + glib::gchar_to_string(session_id),107 {
108 "org.freedesktop.login1.Session",108 CallLogindMethod("GetSession", g_variant_new("(s)", session_id.c_str()), [this, session_id] (GVariant* variant, glib::Error const& err) {
109 test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,109 std::string session_path;
110 G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES);110
111111 if (!err && variant)
112 login_proxy_->Connect("Lock", [this](GVariant*){112 session_path = glib::Variant(variant).GetObjectPath();
113 manager_->PromptLockScreen();113
114 });114 if (session_path.empty())
115115 session_path = "/org/freedesktop/login1/session/" + session_id;
116 login_proxy_->Connect("Unlock", [this](GVariant*){116
117 manager_->unlock_requested.emit();117 SetupLogin1Proxy(session_path);
118 });118 });
119119 }
120 login_proxy_->ConnectProperty("Active", [this] (GVariant* variant) {120 else
121 bool active = glib::Variant(variant).GetBool();121 {
122 manager_->is_session_active.changed.emit(active);122 auto proxy = std::make_shared<glib::DBusProxy>("org.freedesktop.login1",
123 if (active)123 "/org/freedesktop/login1/user/self",
124 manager_->screensaver_requested.emit(false);124 "org.freedesktop.login1.User",
125 });125 G_BUS_TYPE_SYSTEM);
126126
127 manager_->is_session_active.SetGetterFunction([this] {127 proxy->GetProperty("Display", [this, proxy] (GVariant *variant) {
128 return login_proxy_->GetProperty("Active").GetBool();128 if (!variant || g_variant_n_children(variant) < 2)
129 });129 return;
130
131 glib::Variant tmp(g_variant_get_child_value(variant, 1), glib::StealRef());
132 SetupLogin1Proxy(tmp.GetObjectPath());
133 });
134 }
130 }135 }
131136
132 {137 {
@@ -221,6 +226,34 @@
221 ClosedDialog();226 ClosedDialog();
222}227}
223228
229void GnomeManager::Impl::SetupLogin1Proxy(std::string const& session_path)
230{
231 login_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1",
232 session_path,
233 "org.freedesktop.login1.Session",
234 test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
235 G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES);
236
237 login_proxy_->Connect("Lock", [this](GVariant*){
238 manager_->PromptLockScreen();
239 });
240
241 login_proxy_->Connect("Unlock", [this](GVariant*){
242 manager_->unlock_requested.emit();
243 });
244
245 login_proxy_->ConnectProperty("Active", [this] (GVariant* variant) {
246 bool active = glib::Variant(variant).GetBool();
247 manager_->is_session_active.changed.emit(active);
248 if (active)
249 manager_->screensaver_requested.emit(false);
250 });
251
252 manager_->is_session_active.SetGetterFunction([this] {
253 return login_proxy_->GetProperty("Active").GetBool();
254 });
255}
256
224bool GnomeManager::Impl::InteractiveMode()257bool GnomeManager::Impl::InteractiveMode()
225{258{
226 bool schema_found = false;259 bool schema_found = false;
227260
=== modified file 'UnityCore/GnomeSessionManagerImpl.h'
--- UnityCore/GnomeSessionManagerImpl.h 2015-12-03 05:57:00 +0000
+++ UnityCore/GnomeSessionManagerImpl.h 2016-11-11 14:53:10 +0000
@@ -46,6 +46,8 @@
46 Impl(GnomeManager* parent, bool test_mode = false);46 Impl(GnomeManager* parent, bool test_mode = false);
47 ~Impl();47 ~Impl();
4848
49 void SetupLogin1Proxy(std::string const& session_path);
50
49 void ConfirmLogout();51 void ConfirmLogout();
50 void ConfirmReboot();52 void ConfirmReboot();
51 void ConfirmShutdown();53 void ConfirmShutdown();
5254
=== modified file 'UnityCore/Variant.cpp'
--- UnityCore/Variant.cpp 2013-11-19 20:28:13 +0000
+++ UnityCore/Variant.cpp 2016-11-11 14:53:10 +0000
@@ -174,6 +174,36 @@
174 return result ? result : "";174 return result ? result : "";
175}175}
176176
177std::string Variant::GetObjectPath() const
178{
179 const gchar *result = nullptr;
180
181 if (!variant_)
182 return "";
183
184 if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_OBJECT_PATH))
185 {
186 // g_variant_get_string doesn't duplicate the string
187 result = g_variant_get_string(variant_, nullptr);
188 }
189 else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(o)")))
190 {
191 // As we're using the '&' prefix we don't need to free the string!
192 g_variant_get(variant_, "(&o)", &result);
193 }
194 else
195 {
196 auto const& variant = get_variant(variant_);
197 if (variant)
198 return variant.GetObjectPath();
199
200 LOG_ERROR(logger) << "You're trying to extract a 'o' from a variant which is of type '"
201 << g_variant_type_peek_string(g_variant_get_type(variant_)) << "'";
202 }
203
204 return result ? result : "";
205}
206
177template <typename TYPE, typename GTYPE>207template <typename TYPE, typename GTYPE>
178TYPE get_numeric_value(GVariant *variant_, const char *type_str, const char *fallback_type_str)208TYPE get_numeric_value(GVariant *variant_, const char *type_str, const char *fallback_type_str)
179{209{
180210
=== modified file 'UnityCore/Variant.h'
--- UnityCore/Variant.h 2013-11-19 20:28:13 +0000
+++ UnityCore/Variant.h 2016-11-11 14:53:10 +0000
@@ -68,6 +68,7 @@
68 ~Variant();68 ~Variant();
6969
70 std::string GetString() const;70 std::string GetString() const;
71 std::string GetObjectPath() const;
71 unsigned char GetByte() const;72 unsigned char GetByte() const;
72 int16_t GetInt16() const;73 int16_t GetInt16() const;
73 uint16_t GetUInt16() const;74 uint16_t GetUInt16() const;
7475
=== modified file 'debian/changelog'
--- debian/changelog 2016-09-06 14:19:16 +0000
+++ debian/changelog 2016-11-11 14:53:10 +0000
@@ -1,3 +1,20 @@
1unity (7.5.0+16.10.20160906.1-0ubuntu2) UNRELEASED; urgency=medium
2
3 [ Marco Trevisan (Treviño) ]
4 * LockScreenController: ignore icon_paths_changed signal in
5 menumanager for Lockscreen (LP: #1635625)
6
7 [ Andrea Azzarone ]
8 * Properly handle the file manager copy dialog in
9 FileManagerLauncherIcon and in StorageLauncherIcon. (LP: #1575452,
10 LP: #1609845)
11 * Correctly position the force quit dialog when scaling is different
12 than 1.0 (LP: #1637991)
13 * GnomeSession: Retrieve the session id using dbus if $XDG_SESSION_ID
14 is not set (LP: #1633749)
15
16 -- Marco Trevisan (Treviño) <mail@3v1n0.net> Fri, 11 Nov 2016 14:45:03 +0100
17
1unity (7.5.0+16.10.20160906.1-0ubuntu1) yakkety; urgency=medium18unity (7.5.0+16.10.20160906.1-0ubuntu1) yakkety; urgency=medium
219
3 [ Marco Trevisan (Treviño), Ted Gould ]20 [ Marco Trevisan (Treviño), Ted Gould ]
421
=== modified file 'decorations/DecorationsForceQuitDialog.cpp'
--- decorations/DecorationsForceQuitDialog.cpp 2016-08-06 16:24:55 +0000
+++ decorations/DecorationsForceQuitDialog.cpp 2016-11-11 14:53:10 +0000
@@ -478,9 +478,11 @@
478478
479 void UpdateDialogPosition()479 void UpdateDialogPosition()
480 {480 {
481 gint scale = gtk_widget_get_scale_factor(dialog_);
482 scale = std::max<gint>(1, scale);
481 auto const& win_geo = win_->inputRect();483 auto const& win_geo = win_->inputRect();
482 nux::Size walloc(gtk_widget_get_allocated_width(dialog_), gtk_widget_get_allocated_height(dialog_));484 nux::Size walloc(gtk_widget_get_allocated_width(dialog_) * scale, gtk_widget_get_allocated_height(dialog_) * scale);
483 gtk_window_move(GTK_WINDOW(dialog_), win_geo.centerX() - walloc.width/2, win_geo.centerY() - walloc.height/2);485 gtk_window_move(GTK_WINDOW(dialog_), (win_geo.centerX() - walloc.width/2) / scale, (win_geo.centerY() - walloc.height/2) / scale);
484 }486 }
485487
486 ForceQuitDialog* parent_;488 ForceQuitDialog* parent_;
487489
=== modified file 'launcher/FileManagerLauncherIcon.cpp'
--- launcher/FileManagerLauncherIcon.cpp 2016-07-05 13:35:56 +0000
+++ launcher/FileManagerLauncherIcon.cpp 2016-11-11 14:53:10 +0000
@@ -49,6 +49,11 @@
49 SetQuirk(Quirk::VISIBLE, false);49 SetQuirk(Quirk::VISIBLE, false);
50 SkipQuirkAnimation(Quirk::VISIBLE);50 SkipQuirkAnimation(Quirk::VISIBLE);
5151
52 signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindowPtr const& win) {
53 signals_conn_.Add(win->monitor.changed.connect([this] (int) { UpdateStorageWindows(); }));
54 UpdateStorageWindows();
55 }));
56
52 signals_conn_.Add(app_->desktop_file.changed.connect([this](std::string const& desktop_file) {57 signals_conn_.Add(app_->desktop_file.changed.connect([this](std::string const& desktop_file) {
53 LOG_DEBUG(logger) << tooltip_text() << " desktop_file now " << desktop_file;58 LOG_DEBUG(logger) << tooltip_text() << " desktop_file now " << desktop_file;
54 UpdateDesktopFile();59 UpdateDesktopFile();
@@ -134,5 +139,30 @@
134 return StorageLauncherIcon::OnShouldHighlightOnDrag(dnd_data);139 return StorageLauncherIcon::OnShouldHighlightOnDrag(dnd_data);
135}140}
136141
142bool FileManagerLauncherIcon::IsUserVisible() const
143{
144 return ApplicationLauncherIcon::IsUserVisible();
145}
146
147WindowList FileManagerLauncherIcon::WindowsOnViewport()
148{
149 WindowFilterMask filter = 0;
150 filter |= WindowFilter::MAPPED;
151 filter |= WindowFilter::ON_CURRENT_DESKTOP;
152 filter |= WindowFilter::ON_ALL_MONITORS;
153
154 return WindowedLauncherIcon::GetWindows(filter);
155}
156
157WindowList FileManagerLauncherIcon::WindowsForMonitor(int monitor)
158{
159 WindowFilterMask filter = 0;
160 filter |= WindowFilter::MAPPED;
161 filter |= WindowFilter::ON_CURRENT_DESKTOP;
162
163 return WindowedLauncherIcon::GetWindows(filter, monitor);
164}
165
166
137} // namespace launcher167} // namespace launcher
138} // namespace unity168} // namespace unity
139169
=== modified file 'launcher/FileManagerLauncherIcon.h'
--- launcher/FileManagerLauncherIcon.h 2015-12-09 12:02:48 +0000
+++ launcher/FileManagerLauncherIcon.h 2016-11-11 14:53:10 +0000
@@ -32,8 +32,16 @@
32class FileManagerLauncherIcon : public ApplicationLauncherIcon, public StorageLauncherIcon32class FileManagerLauncherIcon : public ApplicationLauncherIcon, public StorageLauncherIcon
33{33{
34public:34public:
35 typedef nux::ObjectPtr<FileManagerLauncherIcon> Ptr;
36
35 FileManagerLauncherIcon(ApplicationPtr const&, DeviceLauncherSection::Ptr const&, FileManager::Ptr const& = nullptr);37 FileManagerLauncherIcon(ApplicationPtr const&, DeviceLauncherSection::Ptr const&, FileManager::Ptr const& = nullptr);
3638
39 bool IsUserVisible() const override;
40
41protected:
42 WindowList WindowsOnViewport() override;
43 WindowList WindowsForMonitor(int monitor) override;
44
37private:45private:
38 WindowList GetManagedWindows() const override;46 WindowList GetManagedWindows() const override;
39 WindowList GetStorageWindows() const override;47 WindowList GetStorageWindows() const override;
4048
=== modified file 'launcher/StorageLauncherIcon.cpp'
--- launcher/StorageLauncherIcon.cpp 2015-12-08 14:31:30 +0000
+++ launcher/StorageLauncherIcon.cpp 2016-11-11 14:53:10 +0000
@@ -36,7 +36,7 @@
36 bool active = false;36 bool active = false;
37 bool urgent = false;37 bool urgent = false;
38 bool check_visibility = (GetIconType() == IconType::APPLICATION);38 bool check_visibility = (GetIconType() == IconType::APPLICATION);
39 bool visible = IsSticky();39 bool visible = false;
4040
41 managed_windows_ = GetStorageWindows();41 managed_windows_ = GetStorageWindows();
42 windows_connections_.Clear();42 windows_connections_.Clear();
@@ -54,13 +54,8 @@
54 if (!urgent && win->urgent())54 if (!urgent && win->urgent())
55 urgent = true;55 urgent = true;
5656
57 if (check_visibility)57 if (check_visibility && !visible)
58 {58 visible = true;
59 windows_connections_.Add(win->visible.changed.connect([this] (bool) { OnWindowStateChanged(); }));
60
61 if (!visible && win->visible())
62 visible = true;
63 }
64 }59 }
6560
66 SetQuirk(Quirk::RUNNING, !managed_windows_.empty());61 SetQuirk(Quirk::RUNNING, !managed_windows_.empty());
@@ -68,7 +63,7 @@
68 SetQuirk(Quirk::URGENT, urgent);63 SetQuirk(Quirk::URGENT, urgent);
6964
70 if (check_visibility)65 if (check_visibility)
71 SetQuirk(Quirk::VISIBLE, visible);66 SetQuirk(Quirk::VISIBLE, visible || IsSticky());
7267
73 EnsureWindowsLocation();68 EnsureWindowsLocation();
74}69}
@@ -83,7 +78,7 @@
83 bool active = false;78 bool active = false;
84 bool urgent = false;79 bool urgent = false;
85 bool check_visibility = (GetIconType() == IconType::APPLICATION);80 bool check_visibility = (GetIconType() == IconType::APPLICATION);
86 bool visible = IsSticky();81 bool visible = false;
8782
88 for (auto const& win : managed_windows_)83 for (auto const& win : managed_windows_)
89 {84 {
@@ -93,7 +88,7 @@
93 if (!urgent && win->urgent())88 if (!urgent && win->urgent())
94 urgent = true;89 urgent = true;
9590
96 if (check_visibility && !visible && win->visible())91 if (check_visibility && !visible)
97 visible = true;92 visible = true;
98 }93 }
9994
@@ -101,7 +96,7 @@
101 SetQuirk(Quirk::URGENT, urgent);96 SetQuirk(Quirk::URGENT, urgent);
10297
103 if (check_visibility)98 if (check_visibility)
104 SetQuirk(Quirk::VISIBLE, visible);99 SetQuirk(Quirk::VISIBLE, visible || IsSticky());
105}100}
106101
107bool StorageLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data)102bool StorageLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data)
108103
=== modified file 'lockscreen/LockScreenController.cpp'
--- lockscreen/LockScreenController.cpp 2016-09-02 13:36:37 +0000
+++ lockscreen/LockScreenController.cpp 2016-11-11 14:53:10 +0000
@@ -467,6 +467,7 @@
467void Controller::LockScreen()467void Controller::LockScreen()
468{468{
469 menu_manager_ = std::make_shared<menu::Manager>(std::make_shared<indicator::LockScreenDBusIndicators>(), key_grabber_);469 menu_manager_ = std::make_shared<menu::Manager>(std::make_shared<indicator::LockScreenDBusIndicators>(), key_grabber_);
470 menu_manager_->Indicators()->icon_paths_changed.clear(); // Ignore custom icon themes for lockscreen, see bug #1635625
470 upstart_wrapper_->Emit("desktop-lock");471 upstart_wrapper_->Emit("desktop-lock");
471 systemd_wrapper_->Start(SYSTEMD_LOCK_TARGET);472 systemd_wrapper_->Start(SYSTEMD_LOCK_TARGET);
472473
473474
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2016-07-20 15:55:32 +0000
+++ tests/CMakeLists.txt 2016-11-11 14:53:10 +0000
@@ -224,6 +224,7 @@
224 test_error_preview.cpp224 test_error_preview.cpp
225 test_edge_barrier_controller.cpp225 test_edge_barrier_controller.cpp
226 test_expo_launcher_icon.cpp226 test_expo_launcher_icon.cpp
227 test_file_manager_launcher_icon.cpp
227 test_filter_widgets.cpp228 test_filter_widgets.cpp
228 test_glib_dbus_server.cpp229 test_glib_dbus_server.cpp
229 test_gnome_session_manager.cpp230 test_gnome_session_manager.cpp
230231
=== added file 'tests/test_file_manager_launcher_icon.cpp'
--- tests/test_file_manager_launcher_icon.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_file_manager_launcher_icon.cpp 2016-11-11 14:53:10 +0000
@@ -0,0 +1,202 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
18 */
19
20#include <gmock/gmock.h>
21using namespace testing;
22
23#include "FileManagerLauncherIcon.h"
24#include "UnityCore/DesktopUtilities.h"
25
26#include "test_mock_devices.h"
27#include "test_mock_filemanager.h"
28#include "mock-application.h"
29
30using namespace unity;
31using namespace unity::launcher;
32using namespace testmocks;
33
34namespace
35{
36
37const std::string TRASH_URI = "trash:";
38const std::string TRASH_PATH = "file://" + DesktopUtilities::GetUserTrashDirectory();
39
40struct TestFileManagerLauncherIcon : public Test
41{
42 TestFileManagerLauncherIcon()
43 : app_(std::make_shared<MockApplication::Nice>())
44 , fm_(std::make_shared<MockFileManager::Nice>())
45 , dev_ (std::make_shared<MockDeviceLauncherSection>(2))
46 , icon_(new FileManagerLauncherIcon(app_, dev_, fm_))
47 {
48 }
49
50 MockApplication::Ptr app_;
51 MockFileManager::Ptr fm_;
52 DeviceLauncherSection::Ptr dev_;
53 FileManagerLauncherIcon::Ptr icon_;
54};
55
56TEST_F(TestFileManagerLauncherIcon, IconType)
57{
58 EXPECT_EQ(icon_->GetIconType(), AbstractLauncherIcon::IconType::APPLICATION);
59}
60
61TEST_F(TestFileManagerLauncherIcon, NoWindow)
62{
63 EXPECT_FALSE(icon_->IsVisible());
64}
65
66TEST_F(TestFileManagerLauncherIcon, NoManagedWindow_TrashUri)
67{
68 EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
69 ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(TRASH_URI));
70
71 auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
72 app_->windows_ = { win };
73 app_->window_opened.emit(win);
74
75 EXPECT_FALSE(icon_->IsVisible());
76 EXPECT_FALSE(icon_->IsRunning());
77}
78
79TEST_F(TestFileManagerLauncherIcon, NoManagedWindow_TrashPath)
80{
81 EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
82 ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(TRASH_PATH));
83
84 auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
85 app_->windows_ = { win };
86 app_->window_opened.emit(win);
87
88 EXPECT_FALSE(icon_->IsVisible());
89 EXPECT_FALSE(icon_->IsRunning());
90}
91
92TEST_F(TestFileManagerLauncherIcon, NoManagedWindow_Device)
93{
94 auto const& device_icons = dev_->GetIcons();
95 ASSERT_EQ(2, device_icons.size());
96
97 device_icons.at(0)->Activate(ActionArg());
98
99 EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
100 ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(device_icons.at(0)->GetVolumeUri()));
101
102 auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
103 app_->windows_ = { win };
104 app_->window_opened.emit(win);
105
106 EXPECT_FALSE(icon_->IsVisible());
107 EXPECT_FALSE(icon_->IsRunning());
108}
109
110TEST_F(TestFileManagerLauncherIcon, ManagedWindows)
111{
112 EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
113 ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return("/usr/bin"));
114
115 auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
116 app_->windows_ = { win };
117 app_->window_opened.emit(win);
118
119 EXPECT_TRUE(icon_->IsVisible());
120 EXPECT_TRUE(icon_->IsRunning());
121}
122
123TEST_F(TestFileManagerLauncherIcon, ManagedWindows_EmptyLocation)
124{
125 EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
126 ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(""));
127
128 auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
129 app_->windows_ = { win };
130 app_->window_opened.emit(win);
131
132 EXPECT_TRUE(icon_->IsVisible());
133 EXPECT_TRUE(icon_->IsRunning());
134}
135
136TEST_F(TestFileManagerLauncherIcon, ManagedWindows_CopyDialog)
137{
138 EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
139 ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(""));
140
141 auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
142 win->visible_ = false;
143 app_->windows_ = { win };
144 app_->window_opened.emit(win);
145
146 EXPECT_TRUE(icon_->IsVisible());
147 EXPECT_TRUE(icon_->IsRunning());
148}
149
150
151TEST_F(TestFileManagerLauncherIcon, ManagedWindows_CopyDialogAndManagedWindow)
152{
153 EXPECT_CALL(*fm_, LocationForWindow(_)).Times(3);
154 ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(""));
155
156 auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
157 app_->windows_ = { win };
158 app_->window_opened.emit(win);
159
160 win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
161 win->visible_ = false;
162 app_->windows_.push_back(win);
163 app_->window_opened.emit(win);
164
165 EXPECT_TRUE(icon_->IsVisible());
166 EXPECT_TRUE(icon_->IsRunning());
167 EXPECT_EQ(2, icon_->WindowsVisibleOnMonitor(0));
168}
169
170TEST_F(TestFileManagerLauncherIcon, ManagedWindows_CopyDialogAndNoManagedWindow)
171{
172 {
173 InSequence s;
174
175 EXPECT_CALL(*fm_, LocationForWindow(_))
176 .Times(1)
177 .WillOnce(Return(""));
178
179 EXPECT_CALL(*fm_, LocationForWindow(_))
180 .Times(1)
181 .WillOnce(Return(""));
182
183 EXPECT_CALL(*fm_, LocationForWindow(_))
184 .Times(1)
185 .WillOnce(Return(TRASH_PATH));
186 }
187
188 auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
189 app_->windows_ = { win };
190 app_->window_opened.emit(win);
191
192 win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
193 win->visible_ = false;
194 app_->windows_.push_back(win);
195 app_->window_opened.emit(win);
196
197 EXPECT_TRUE(icon_->IsVisible());
198 EXPECT_TRUE(icon_->IsRunning());
199 EXPECT_EQ(1, icon_->WindowsVisibleOnMonitor(0));
200}
201
202}
0203
=== modified file 'tests/test_gnome_session_manager.cpp'
--- tests/test_gnome_session_manager.cpp 2016-05-17 02:14:33 +0000
+++ tests/test_gnome_session_manager.cpp 2016-11-11 14:53:10 +0000
@@ -70,6 +70,9 @@
70const std::string LOGIND_MANAGER =70const std::string LOGIND_MANAGER =
71R"(<node>71R"(<node>
72 <interface name="org.freedesktop.login1.Manager">72 <interface name="org.freedesktop.login1.Manager">
73 <method name="GetSession">
74 <arg type="s" name="result" direction="out"/>
75 </method>
73 <method name="CanSuspend">76 <method name="CanSuspend">
74 <arg type="s" name="result" direction="out"/>77 <arg type="s" name="result" direction="out"/>
75 </method>78 </method>
@@ -186,7 +189,11 @@
186 logind_->AddObjects(introspection::LOGIND_MANAGER, LOGIND_MANAGER_PATH);189 logind_->AddObjects(introspection::LOGIND_MANAGER, LOGIND_MANAGER_PATH);
187 logind_->AddObjects(introspection::LOGIND_SESSION, LOGIND_SESSION_PATH);190 logind_->AddObjects(introspection::LOGIND_SESSION, LOGIND_SESSION_PATH);
188 logind_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant*) -> GVariant* {191 logind_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant*) -> GVariant* {
189 if (method == "CanSuspend")192 if (method == "GetSession")
193 {
194 return g_variant_new("(o)", "id0");
195 }
196 else if (method == "CanSuspend")
190 {197 {
191 suspend_called = true;198 suspend_called = true;
192 return g_variant_new("(s)", can_suspend_ ? "yes" : "no");199 return g_variant_new("(s)", can_suspend_ ? "yes" : "no");

Subscribers

People subscribed via source and target branches

to all changes: