Merge lp:~renatofilho/indicator-transfer/source-clear-fix into lp:indicator-transfer/15.10

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Charles Kerr
Approved revision: 57
Merged at revision: 34
Proposed branch: lp:~renatofilho/indicator-transfer/source-clear-fix
Merge into: lp:indicator-transfer/15.10
Prerequisite: lp:~charlesk/indicator-transfer/add-plugins
Diff against target: 1004 lines (+198/-123)
21 files modified
CMakeLists.txt (+1/-1)
data/indicator-transfer.pc.in (+3/-0)
debian/changelog (+6/-0)
include/transfer/controller.h (+9/-3)
include/transfer/dm-source.h (+2/-1)
include/transfer/model.h (+2/-0)
include/transfer/multisource.h (+3/-2)
include/transfer/source.h (+2/-1)
include/transfer/view-gmenu.h (+3/-4)
src/controller.cpp (+43/-14)
src/dm-plugin/dm-source.cpp (+23/-13)
src/main.cpp (+2/-3)
src/model.cpp (+10/-0)
src/multisource.cpp (+13/-1)
src/view-gmenu.cpp (+16/-24)
tests/controller-mock.h (+2/-3)
tests/source-mock.h (+9/-2)
tests/test-controller.cpp (+22/-18)
tests/test-multisource.cpp (+8/-8)
tests/test-plugin-source.cpp (+1/-4)
tests/test-view-gmenu.cpp (+18/-21)
To merge this branch: bzr merge lp:~renatofilho/indicator-transfer/source-clear-fix
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+267690@code.launchpad.net

Commit message

Added 'clear' function into the Source interface.
Call 'Source.clear' in the 'Controller.clear_all' function.
Does not keep a separated copy of source model inside of the Controller class.
Changed the return of 'Source.get_model()' to const.
Update unit tests.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
54. By Renato Araujo Oliveira Filho

Fix warnings from cppcheck test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
55. By Renato Araujo Oliveira Filho

[DM-Plugin] Add download on removed list only if it was removed by 'clear' function.

56. By Renato Araujo Oliveira Filho

Avoid pass a model to GMenuView. Instead use the controller model.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
57. By Renato Araujo Oliveira Filho

Fixed cppcheck errors.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Looks great.

Also, the "explicit" warning in cppcheck always bites me too ;)

review: Approve
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

Are there any related MPs required for this MP to build/function as expected?
YES: lp:~charlesk/indicator-transfer/add-plugins

Is your branch in sync with latest trunk?
YES

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
YES

Did you successfully run all tests found in your component's Test Plan on device or emulator?
YES

If you changed the UI, was the change specified/approved by design?
NO UI CHANGED

If you changed UI labels, did you update the pot file?
NO LABEL CHANGED

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
NO PACKAGE CHANGED

58. By Renato Araujo Oliveira Filho

Parent branch merged.

59. By Renato Araujo Oliveira Filho

Added "Requires" packages into .pc file.

60. By Renato Araujo Oliveira Filho

Update version to 0.2

61. By Renato Araujo Oliveira Filho

Added 'plugindir' variable into .pc file.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-08-19 18:01:58 +0000
+++ CMakeLists.txt 2015-08-19 18:01:58 +0000
@@ -30,7 +30,7 @@
3030
31set(INDICATOR_TRANSFER_VERSION_MAJOR 0)31set(INDICATOR_TRANSFER_VERSION_MAJOR 0)
32set(INDICATOR_TRANSFER_VERSION_MINOR 0)32set(INDICATOR_TRANSFER_VERSION_MINOR 0)
33set(INDICATOR_TRANSFER_VERSION_PATCH 1)33set(INDICATOR_TRANSFER_VERSION_PATCH 2)
34set(INDICATOR_TRANSFER_VERSION "${INDICATOR_TRANSFER_VERSION_MAJOR}.${INDICATOR_TRANSFER_VERSION_MINOR}.${INDICATOR_TRANSFER_VERSION_PATCH}")34set(INDICATOR_TRANSFER_VERSION "${INDICATOR_TRANSFER_VERSION_MAJOR}.${INDICATOR_TRANSFER_VERSION_MINOR}.${INDICATOR_TRANSFER_VERSION_PATCH}")
3535
36##36##
3737
=== modified file 'data/indicator-transfer.pc.in'
--- data/indicator-transfer.pc.in 2015-08-19 18:01:58 +0000
+++ data/indicator-transfer.pc.in 2015-08-19 18:01:58 +0000
@@ -1,8 +1,11 @@
1libdir=@CMAKE_INSTALL_FULL_LIBDIR@1libdir=@CMAKE_INSTALL_FULL_LIBDIR@
2includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@/@CMAKE_PROJECT_NAME@2includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@/@CMAKE_PROJECT_NAME@
3plugindir=@CMAKE_INSTALL_FULL_PKGLIBEXECDIR@
34
4Name: @CMAKE_PROJECT_NAME@5Name: @CMAKE_PROJECT_NAME@
5Description: Developer files for @CMAKE_PROJECT_NAME@6Description: Developer files for @CMAKE_PROJECT_NAME@
6Version: @INDICATOR_TRANSFER_VERSION@7Version: @INDICATOR_TRANSFER_VERSION@
7Libs: -L${libdir} -lindicator-transfer8Libs: -L${libdir} -lindicator-transfer
8Cflags: -I${includedir}9Cflags: -I${includedir}
10Requires: properties-cpp, gmodule-2.0
11
912
=== modified file 'debian/changelog'
--- debian/changelog 2015-08-13 14:15:58 +0000
+++ debian/changelog 2015-08-19 18:01:58 +0000
@@ -1,3 +1,9 @@
1indicator-transfer (0.2-0buntu1) UNRELEASED; urgency=medium
2
3 * Update version to 0.2
4
5 -- Renato Araujo Oliveira Filho <renato.filho@canonical.com> Wed, 19 Aug 2015 14:52:32 -0300
6
1indicator-transfer (0.1+15.10.20150727-0ubuntu2~gcc5.1) wily; urgency=medium7indicator-transfer (0.1+15.10.20150727-0ubuntu2~gcc5.1) wily; urgency=medium
28
3 * No change rebuild using GCC 5.9 * No change rebuild using GCC 5.
410
=== modified file 'include/transfer/controller.h'
--- include/transfer/controller.h 2015-08-19 18:01:58 +0000
+++ include/transfer/controller.h 2015-08-19 18:01:58 +0000
@@ -36,8 +36,7 @@
36class Controller36class Controller
37{37{
38public:38public:
39 Controller(const std::shared_ptr<MutableModel>& model,39 explicit Controller(const std::shared_ptr<Source>& source);
40 const std::shared_ptr<Source>& source);
41 virtual ~Controller();40 virtual ~Controller();
4241
43 virtual void pause_all();42 virtual void pause_all();
@@ -48,12 +47,19 @@
48 virtual void pause(const Transfer::Id&);47 virtual void pause(const Transfer::Id&);
49 virtual void cancel(const Transfer::Id&);48 virtual void cancel(const Transfer::Id&);
50 virtual void resume(const Transfer::Id&);49 virtual void resume(const Transfer::Id&);
50 virtual void clear(const Transfer::Id&);
51 virtual void open(const Transfer::Id&);51 virtual void open(const Transfer::Id&);
52 virtual void open_app(const Transfer::Id&);52 virtual void open_app(const Transfer::Id&);
5353
54 int size() const;
55 int count(const Transfer::Id&) const;
56 const std::shared_ptr<const MutableModel> get_model();
57
54private:58private:
55 std::shared_ptr<MutableModel> m_model;
56 std::shared_ptr<Source> m_source;59 std::shared_ptr<Source> m_source;
60
61 std::set<Transfer::Id> get_ids() const;
62 std::shared_ptr<Transfer> get(const Transfer::Id& id) const;
57};63};
5864
59} // namespace transfer65} // namespace transfer
6066
=== modified file 'include/transfer/dm-source.h'
--- include/transfer/dm-source.h 2015-08-19 18:01:58 +0000
+++ include/transfer/dm-source.h 2015-08-19 18:01:58 +0000
@@ -44,8 +44,9 @@
44 void pause(const Transfer::Id& id) override;44 void pause(const Transfer::Id& id) override;
45 void resume(const Transfer::Id& id) override;45 void resume(const Transfer::Id& id) override;
46 void cancel(const Transfer::Id& id) override;46 void cancel(const Transfer::Id& id) override;
47 void clear(const Transfer::Id& id) override;
47 void open_app(const Transfer::Id& id) override;48 void open_app(const Transfer::Id& id) override;
48 std::shared_ptr<MutableModel> get_model() override;49 const std::shared_ptr<const MutableModel> get_model() override;
4950
50private:51private:
51 class Impl;52 class Impl;
5253
=== modified file 'include/transfer/model.h'
--- include/transfer/model.h 2014-06-17 01:36:16 +0000
+++ include/transfer/model.h 2015-08-19 18:01:58 +0000
@@ -42,6 +42,8 @@
42 std::set<Transfer::Id> get_ids() const;42 std::set<Transfer::Id> get_ids() const;
43 std::vector<std::shared_ptr<Transfer>> get_all() const;43 std::vector<std::shared_ptr<Transfer>> get_all() const;
44 std::shared_ptr<Transfer> get(const Transfer::Id&) const;44 std::shared_ptr<Transfer> get(const Transfer::Id&) const;
45 int size() const;
46 int count(const Transfer::Id&) const;
4547
46 const core::Signal<Transfer::Id>& changed() const;48 const core::Signal<Transfer::Id>& changed() const;
47 const core::Signal<Transfer::Id>& added() const;49 const core::Signal<Transfer::Id>& added() const;
4850
=== modified file 'include/transfer/multisource.h'
--- include/transfer/multisource.h 2015-08-19 18:01:58 +0000
+++ include/transfer/multisource.h 2015-08-19 18:01:58 +0000
@@ -35,14 +35,15 @@
35 MultiSource();35 MultiSource();
36 virtual ~MultiSource();36 virtual ~MultiSource();
3737
38 // Source 38 // Source
39 void open(const Transfer::Id& id) override;39 void open(const Transfer::Id& id) override;
40 void start(const Transfer::Id& id) override;40 void start(const Transfer::Id& id) override;
41 void pause(const Transfer::Id& id) override;41 void pause(const Transfer::Id& id) override;
42 void resume(const Transfer::Id& id) override;42 void resume(const Transfer::Id& id) override;
43 void cancel(const Transfer::Id& id) override;43 void cancel(const Transfer::Id& id) override;
44 void clear(const Transfer::Id& id) override;
44 void open_app(const Transfer::Id& id) override;45 void open_app(const Transfer::Id& id) override;
45 std::shared_ptr<MutableModel> get_model() override;46 const std::shared_ptr<const MutableModel> get_model() override;
4647
47 void add_source(const std::shared_ptr<Source>& source);48 void add_source(const std::shared_ptr<Source>& source);
4849
4950
=== modified file 'include/transfer/source.h'
--- include/transfer/source.h 2015-08-19 18:01:58 +0000
+++ include/transfer/source.h 2015-08-19 18:01:58 +0000
@@ -50,9 +50,10 @@
50 virtual void pause(const Transfer::Id& id) =0;50 virtual void pause(const Transfer::Id& id) =0;
51 virtual void resume(const Transfer::Id& id) =0;51 virtual void resume(const Transfer::Id& id) =0;
52 virtual void cancel(const Transfer::Id& id) =0;52 virtual void cancel(const Transfer::Id& id) =0;
53 virtual void clear(const Transfer::Id& id) =0;
53 virtual void open_app(const Transfer::Id& id) =0;54 virtual void open_app(const Transfer::Id& id) =0;
5455
55 virtual std::shared_ptr<MutableModel> get_model() =0;56 virtual const std::shared_ptr<const MutableModel> get_model() =0;
56};57};
5758
58} // namespace transfer59} // namespace transfer
5960
=== modified file 'include/transfer/view-gmenu.h'
--- include/transfer/view-gmenu.h 2014-06-17 01:36:16 +0000
+++ include/transfer/view-gmenu.h 2015-08-19 18:01:58 +0000
@@ -32,16 +32,15 @@
32class GMenuView32class GMenuView
33{33{
34public:34public:
35 GMenuView(const std::shared_ptr<Model>& model,35 explicit GMenuView(const std::shared_ptr<Controller>& controller);
36 const std::shared_ptr<Controller>& controller);
37 ~GMenuView();36 ~GMenuView();
38 void set_controller(const std::shared_ptr<Controller>&);
39 void set_model(const std::shared_ptr<Model>&);
40 const core::Signal<>& name_lost() const;37 const core::Signal<>& name_lost() const;
4138
42private:39private:
43 class Impl;40 class Impl;
44 std::unique_ptr<Impl> p;41 std::unique_ptr<Impl> p;
42
43 void set_model(const std::shared_ptr<Model>&);
45};44};
4645
47} // namespace transfer46} // namespace transfer
4847
=== modified file 'src/controller.cpp'
--- src/controller.cpp 2015-08-19 18:01:58 +0000
+++ src/controller.cpp 2015-08-19 18:01:58 +0000
@@ -27,9 +27,7 @@
27****27****
28***/28***/
2929
30Controller::Controller(const std::shared_ptr<MutableModel>& model,30Controller::Controller(const std::shared_ptr<Source>& source):
31 const std::shared_ptr<Source>& source):
32 m_model(model),
33 m_source(source)31 m_source(source)
34{32{
35}33}
@@ -40,26 +38,25 @@
4038
41void Controller::pause_all()39void Controller::pause_all()
42{40{
43 for(const auto& id : m_model->get_ids())41 for(const auto& id : get_ids())
44 pause(id);42 pause(id);
45}43}
4644
47void Controller::resume_all()45void Controller::resume_all()
48{46{
49 for(const auto& id : m_model->get_ids())47 for(const auto& id : get_ids())
50 resume(id);48 resume(id);
51}49}
5250
53void Controller::clear_all()51void Controller::clear_all()
54{52{
55 for (const auto& transfer : m_model->get_all())53 for (const auto& id : get_ids())
56 if (transfer->can_clear())54 clear(id);
57 m_model->remove(transfer->id);
58}55}
5956
60void Controller::tap(const Transfer::Id& id)57void Controller::tap(const Transfer::Id& id)
61{58{
62 const auto transfer = m_model->get(id);59 const auto transfer = get(id);
63 g_return_if_fail (transfer);60 g_return_if_fail (transfer);
6461
65 if (transfer->can_start())62 if (transfer->can_start())
@@ -75,28 +72,35 @@
7572
76void Controller::pause(const Transfer::Id& id)73void Controller::pause(const Transfer::Id& id)
77{74{
78 const auto& transfer = m_model->get(id);75 const auto& transfer = get(id);
79 if (transfer && transfer->can_pause())76 if (transfer && transfer->can_pause())
80 m_source->pause(id);77 m_source->pause(id);
81}78}
8279
83void Controller::cancel(const Transfer::Id& id)80void Controller::cancel(const Transfer::Id& id)
84{81{
85 const auto& transfer = m_model->get(id);82 const auto& transfer = get(id);
86 if (transfer && transfer->can_cancel())83 if (transfer && transfer->can_cancel())
87 m_source->cancel(id);84 m_source->cancel(id);
88}85}
8986
87void Controller::clear(const Transfer::Id& id)
88{
89 const auto& transfer = get(id);
90 if (transfer && transfer->can_clear())
91 m_source->clear(id);
92}
93
90void Controller::resume(const Transfer::Id& id)94void Controller::resume(const Transfer::Id& id)
91{95{
92 const auto& transfer = m_model->get(id);96 const auto& transfer = get(id);
93 if (transfer && transfer->can_resume())97 if (transfer && transfer->can_resume())
94 m_source->resume(id);98 m_source->resume(id);
95}99}
96100
97void Controller::start(const Transfer::Id& id)101void Controller::start(const Transfer::Id& id)
98{102{
99 const auto& transfer = m_model->get(id);103 const auto& transfer = get(id);
100 if (transfer && transfer->can_start())104 if (transfer && transfer->can_start())
101 m_source->start(id);105 m_source->start(id);
102}106}
@@ -108,7 +112,32 @@
108112
109void Controller::open_app(const Transfer::Id& id)113void Controller::open_app(const Transfer::Id& id)
110{114{
111 m_source->open_app(id);115 m_source->open_app(id);
116}
117
118int Controller::size() const
119{
120 return m_source->get_model()->size();
121}
122
123int Controller::count(const Transfer::Id& id) const
124{
125 return m_source->get_model()->count(id);
126}
127
128const std::shared_ptr<const MutableModel> Controller::get_model()
129{
130 return m_source->get_model();
131}
132
133std::set<Transfer::Id> Controller::get_ids() const
134{
135 return m_source->get_model()->get_ids();
136}
137
138std::shared_ptr<Transfer> Controller::get(const Transfer::Id& id) const
139{
140 return m_source->get_model()->get(id);
112}141}
113142
114/***143/***
115144
=== modified file 'src/dm-plugin/dm-source.cpp'
--- src/dm-plugin/dm-source.cpp 2015-08-19 18:01:58 +0000
+++ src/dm-plugin/dm-source.cpp 2015-08-19 18:01:58 +0000
@@ -43,7 +43,7 @@
4343
44/**44/**
45 * A Transfer whose state comes from content-hub and ubuntu-download-manager.45 * A Transfer whose state comes from content-hub and ubuntu-download-manager.
46 * 46 *
47 * Each DMTransfer tracks a com.canonical.applications.Download (ccad) object47 * Each DMTransfer tracks a com.canonical.applications.Download (ccad) object
48 * from ubuntu-download-manager. The ccad is used for pause/resume/cancel,48 * from ubuntu-download-manager. The ccad is used for pause/resume/cancel,
49 * state change / download progress signals, etc.49 * state change / download progress signals, etc.
@@ -85,14 +85,14 @@
85 void start()85 void start()
86 {86 {
87 g_return_if_fail(can_start());87 g_return_if_fail(can_start());
88 88
89 call_ccad_method_no_args_no_response("start");89 call_ccad_method_no_args_no_response("start");
90 }90 }
9191
92 void pause()92 void pause()
93 {93 {
94 g_return_if_fail(can_pause());94 g_return_if_fail(can_pause());
95 95
96 call_ccad_method_no_args_no_response("pause");96 call_ccad_method_no_args_no_response("pause");
97 }97 }
9898
@@ -359,7 +359,7 @@
359 speed_Bps = 0;359 speed_Bps = 0;
360 m_history.clear();360 m_history.clear();
361 }361 }
362 362
363 emit_changed_soon();363 emit_changed_soon();
364 }364 }
365 }365 }
@@ -631,12 +631,6 @@
631 m_model(std::make_shared<MutableModel>())631 m_model(std::make_shared<MutableModel>())
632 {632 {
633 g_bus_get(G_BUS_TYPE_SESSION, m_cancellable, on_bus_ready, this);633 g_bus_get(G_BUS_TYPE_SESSION, m_cancellable, on_bus_ready, this);
634
635 m_model->removed().connect([this](const Transfer::Id& id){
636 auto transfer = find_transfer_by_id(id);
637 if (transfer)
638 m_removed_ccad.insert(transfer->ccad_path());
639 });
640 }634 }
641635
642 ~Impl()636 ~Impl()
@@ -675,6 +669,16 @@
675 transfer->cancel();669 transfer->cancel();
676 }670 }
677671
672 void clear(const Transfer::Id& id)
673 {
674 auto transfer = find_transfer_by_id(id);
675 if (transfer)
676 {
677 m_removed_ccad.insert(transfer->ccad_path());
678 m_model->remove(id);
679 }
680 }
681
678 void open(const Transfer::Id& id)682 void open(const Transfer::Id& id)
679 {683 {
680 auto transfer = find_transfer_by_id(id);684 auto transfer = find_transfer_by_id(id);
@@ -812,7 +816,7 @@
812 g_debug("download signal: %s %s %s", ccad_path, signal_name, variant_str);816 g_debug("download signal: %s %s %s", ccad_path, signal_name, variant_str);
813 g_free(variant_str);817 g_free(variant_str);
814818
815 // Route this signal to the DMTransfer for processing 819 // Route this signal to the DMTransfer for processing
816 auto self = static_cast<Impl*>(gself);820 auto self = static_cast<Impl*>(gself);
817 auto transfer = self->find_transfer_by_ccad_path(ccad_path);821 auto transfer = self->find_transfer_by_ccad_path(ccad_path);
818 if (transfer)822 if (transfer)
@@ -927,12 +931,18 @@
927}931}
928932
929void933void
934DMSource::clear(const Transfer::Id& id)
935{
936 impl->clear(id);
937}
938
939void
930DMSource::open_app(const Transfer::Id& id)940DMSource::open_app(const Transfer::Id& id)
931{941{
932 impl->open_app(id);942 impl->open_app(id);
933}943}
934944
935std::shared_ptr<MutableModel>945const std::shared_ptr<const MutableModel>
936DMSource::get_model()946DMSource::get_model()
937{947{
938 return impl->get_model();948 return impl->get_model();
939949
=== modified file 'src/main.cpp'
--- src/main.cpp 2015-08-19 18:01:58 +0000
+++ src/main.cpp 2015-08-19 18:01:58 +0000
@@ -45,9 +45,8 @@
4545
46 // run until we lose the busname46 // run until we lose the busname
47 auto source = std::make_shared<PluginSource>(PLUGINDIR);47 auto source = std::make_shared<PluginSource>(PLUGINDIR);
48 auto model = source->get_model();48 auto controller = std::make_shared<Controller>(source);
49 auto controller = std::make_shared<Controller>(model, source);49 GMenuView menu_view (controller);
50 GMenuView menu_view (model, controller);
51 // FIXME: listen for busname-lost50 // FIXME: listen for busname-lost
52 g_main_loop_run(loop);51 g_main_loop_run(loop);
5352
5453
=== modified file 'src/model.cpp'
--- src/model.cpp 2014-06-17 01:36:16 +0000
+++ src/model.cpp 2015-08-19 18:01:58 +0000
@@ -58,6 +58,16 @@
58 return ret;58 return ret;
59}59}
6060
61int Model::size() const
62{
63 return m_transfers.size();
64}
65
66int Model::count(const Transfer::Id& id) const
67{
68 return m_transfers.count(id);
69}
70
61const core::Signal<Transfer::Id>& Model::changed() const71const core::Signal<Transfer::Id>& Model::changed() const
62{72{
63 return m_changed;73 return m_changed;
6474
=== modified file 'src/multisource.cpp'
--- src/multisource.cpp 2015-08-19 18:01:58 +0000
+++ src/multisource.cpp 2015-08-19 18:01:58 +0000
@@ -104,6 +104,13 @@
104 source->cancel(id);104 source->cancel(id);
105 }105 }
106106
107 void clear(const Transfer::Id& id)
108 {
109 auto source = lookup_source(id);
110 g_return_if_fail(source);
111 source->clear(id);
112 }
113
107 void open(const Transfer::Id& id)114 void open(const Transfer::Id& id)
108 {115 {
109 auto source = lookup_source(id);116 auto source = lookup_source(id);
@@ -180,13 +187,18 @@
180 impl->cancel(id);187 impl->cancel(id);
181}188}
182189
190void MultiSource::clear(const Transfer::Id &id)
191{
192 impl->clear(id);
193}
194
183void195void
184MultiSource::open_app(const Transfer::Id& id)196MultiSource::open_app(const Transfer::Id& id)
185{197{
186 impl->open_app(id);198 impl->open_app(id);
187}199}
188200
189std::shared_ptr<MutableModel>201const std::shared_ptr<const MutableModel>
190MultiSource::get_model()202MultiSource::get_model()
191{203{
192 return impl->get_model();204 return impl->get_model();
193205
=== modified file 'src/view-gmenu.cpp'
--- src/view-gmenu.cpp 2014-10-03 20:54:45 +0000
+++ src/view-gmenu.cpp 2015-08-19 18:01:58 +0000
@@ -43,12 +43,11 @@
43{43{
44public:44public:
4545
46 GActions(const std::shared_ptr<Model>& model,46 explicit GActions(const std::shared_ptr<Controller>& controller):
47 const std::shared_ptr<Controller>& controller):
48 m_action_group(g_simple_action_group_new()),47 m_action_group(g_simple_action_group_new()),
49 m_controller(controller)48 m_controller(controller)
50 {49 {
51 set_model(model);50 set_model(controller->get_model());
5251
53 const GActionEntry entries[] = {52 const GActionEntry entries[] = {
54 { "activate-transfer", on_tap, "s", nullptr },53 { "activate-transfer", on_tap, "s", nullptr },
@@ -75,7 +74,7 @@
7574
76 }75 }
7776
78 void set_model(const std::shared_ptr<Model>& model)77 void set_model(const std::shared_ptr<const Model>& model)
79 {78 {
80 // out with the old...79 // out with the old...
81 auto& c = m_connections;80 auto& c = m_connections;
@@ -252,7 +251,7 @@
252 }251 }
253252
254 GSimpleActionGroup* m_action_group = nullptr;253 GSimpleActionGroup* m_action_group = nullptr;
255 std::shared_ptr<Model> m_model;254 std::shared_ptr<const Model> m_model;
256 std::shared_ptr<Controller> m_controller;255 std::shared_ptr<Controller> m_controller;
257 std::set<core::ScopedConnection> m_connections;256 std::set<core::ScopedConnection> m_connections;
258257
@@ -279,7 +278,7 @@
279 GMenuModel* menu_model() { return G_MENU_MODEL(m_menu); }278 GMenuModel* menu_model() { return G_MENU_MODEL(m_menu); }
280279
281 Menu(const char* name_in,280 Menu(const char* name_in,
282 const std::shared_ptr<Model>& model,281 const std::shared_ptr<const Model>& model,
283 const std::shared_ptr<GActions>& gactions):282 const std::shared_ptr<GActions>& gactions):
284 m_name{name_in},283 m_name{name_in},
285 m_gactions{gactions}284 m_gactions{gactions}
@@ -296,7 +295,7 @@
296 g_clear_object(&m_menu);295 g_clear_object(&m_menu);
297 }296 }
298297
299 void set_model (const std::shared_ptr<Model>& model)298 void set_model (const std::shared_ptr<const Model>& model)
300 {299 {
301 auto& c = m_connections;300 auto& c = m_connections;
302 c.clear();301 c.clear();
@@ -563,7 +562,7 @@
563 return item;562 return item;
564 }563 }
565564
566 static bool bulk_menu_item_is_equal(GMenuModel* model, 565 static bool bulk_menu_item_is_equal(GMenuModel* model,
567 int pos,566 int pos,
568 GMenuItem* item)567 GMenuItem* item)
569 {568 {
@@ -772,7 +771,7 @@
772 GMenu* m_menu = nullptr;771 GMenu* m_menu = nullptr;
773 const char* const m_name;772 const char* const m_name;
774773
775 std::shared_ptr<Model> m_model;774 std::shared_ptr<const Model> m_model;
776 std::shared_ptr<GActions> m_gactions;775 std::shared_ptr<GActions> m_gactions;
777 std::map<Transfer::Id,Section> m_visible_transfers;776 std::map<Transfer::Id,Section> m_visible_transfers;
778 GMenu* m_submenu = nullptr;777 GMenu* m_submenu = nullptr;
@@ -936,17 +935,16 @@
936{935{
937public:936public:
938937
939 Impl (const std::shared_ptr<Model>& model,938 explicit Impl (const std::shared_ptr<Controller>& controller):
940 const std::shared_ptr<Controller>& controller):
941 m_model(model),
942 m_controller(controller),939 m_controller(controller),
943 m_gactions(new GActions(model, controller)),940 m_gactions(new GActions(controller)),
944 m_exporter(new Exporter)941 m_exporter(new Exporter)
945 {942 {
943 set_model(controller->get_model());
946 // create the Menus944 // create the Menus
947 for(int i=0; i<Menu::NUM_PROFILES; i++)945 for(int i=0; i<Menu::NUM_PROFILES; i++)
948 m_menus.push_back(create_menu_for_profile(Menu::Profile(i)));946 m_menus.push_back(create_menu_for_profile(Menu::Profile(i)));
949 947
950 m_exporter->publish(m_gactions, m_menus);948 m_exporter->publish(m_gactions, m_menus);
951 }949 }
952950
@@ -954,7 +952,7 @@
954 {952 {
955 }953 }
956954
957 void set_model(const std::shared_ptr<Model>& model)955 void set_model(const std::shared_ptr<const Model>& model)
958 {956 {
959 m_model = model;957 m_model = model;
960958
@@ -976,7 +974,7 @@
976 return m;974 return m;
977 }975 }
978976
979 std::shared_ptr<Model> m_model;977 std::shared_ptr<const Model> m_model;
980 std::shared_ptr<Controller> m_controller;978 std::shared_ptr<Controller> m_controller;
981 std::shared_ptr<GActions> m_gactions;979 std::shared_ptr<GActions> m_gactions;
982 std::vector<std::shared_ptr<Menu>> m_menus;980 std::vector<std::shared_ptr<Menu>> m_menus;
@@ -987,9 +985,8 @@
987****985****
988***/986***/
989987
990GMenuView::GMenuView(const std::shared_ptr<Model>& model,988GMenuView::GMenuView(const std::shared_ptr<Controller>& controller):
991 const std::shared_ptr<Controller>& controller):989 p(new Impl(controller))
992 p(new Impl(model, controller))
993{990{
994}991}
995992
@@ -997,11 +994,6 @@
997{994{
998}995}
999996
1000void GMenuView::set_model(const std::shared_ptr<Model>& model)
1001{
1002 p->set_model(model);
1003}
1004
1005const core::Signal<>& GMenuView::name_lost() const997const core::Signal<>& GMenuView::name_lost() const
1006{998{
1007 return p->name_lost();999 return p->name_lost();
10081000
=== modified file 'tests/controller-mock.h'
--- tests/controller-mock.h 2015-08-19 18:01:58 +0000
+++ tests/controller-mock.h 2015-08-19 18:01:58 +0000
@@ -31,9 +31,8 @@
31class MockController: public Controller31class MockController: public Controller
32{32{
33public:33public:
34 MockController(const std::shared_ptr<MutableModel>& model, 34 explicit MockController(const std::shared_ptr<Source>& source):
35 const std::shared_ptr<Source>& source):35 Controller(source) {}
36 Controller(model, source) {}
3736
38 MOCK_METHOD0(pause_all, void());37 MOCK_METHOD0(pause_all, void());
39 MOCK_METHOD0(resume_all, void());38 MOCK_METHOD0(resume_all, void());
4039
=== modified file 'tests/source-mock.h'
--- tests/source-mock.h 2015-08-19 18:01:58 +0000
+++ tests/source-mock.h 2015-08-19 18:01:58 +0000
@@ -34,16 +34,23 @@
34class MockSource: public Source34class MockSource: public Source
35{35{
36public:36public:
37 MockSource(): m_model(new MutableModel) {}37 MockSource(): m_model(new MutableModel)
38 {
39 // make sure that the transfer get removed from model on clear call
40 ON_CALL(*this, clear(::testing::_))
41 .WillByDefault(::testing::Invoke(m_model.get(), &MutableModel::remove));
42 }
3843
39 MOCK_METHOD1(open, void(const Transfer::Id&));44 MOCK_METHOD1(open, void(const Transfer::Id&));
40 MOCK_METHOD1(start, void(const Transfer::Id&));45 MOCK_METHOD1(start, void(const Transfer::Id&));
41 MOCK_METHOD1(pause, void(const Transfer::Id&));46 MOCK_METHOD1(pause, void(const Transfer::Id&));
42 MOCK_METHOD1(resume, void(const Transfer::Id&));47 MOCK_METHOD1(resume, void(const Transfer::Id&));
43 MOCK_METHOD1(cancel, void(const Transfer::Id&));48 MOCK_METHOD1(cancel, void(const Transfer::Id&));
49 MOCK_METHOD1(clear, void(const Transfer::Id&));
50 MOCK_METHOD1(update, void(const Transfer::Id&));
44 MOCK_METHOD1(open_app, void(const Transfer::Id&));51 MOCK_METHOD1(open_app, void(const Transfer::Id&));
4552
46 std::shared_ptr<MutableModel> get_model() override {return m_model;}53 const std::shared_ptr<const MutableModel> get_model() override {return m_model;}
47 std::shared_ptr<MutableModel> m_model;54 std::shared_ptr<MutableModel> m_model;
48};55};
4956
5057
=== modified file 'tests/test-controller.cpp'
--- tests/test-controller.cpp 2015-08-19 18:01:58 +0000
+++ tests/test-controller.cpp 2015-08-19 18:01:58 +0000
@@ -36,7 +36,6 @@
36 GTestDBus* bus = nullptr;36 GTestDBus* bus = nullptr;
3737
38 std::shared_ptr<MockSource> m_source;38 std::shared_ptr<MockSource> m_source;
39 std::shared_ptr<MutableModel> m_model;
40 std::shared_ptr<Controller> m_controller;39 std::shared_ptr<Controller> m_controller;
4140
42 void SetUp()41 void SetUp()
@@ -44,14 +43,12 @@
44 super::SetUp();43 super::SetUp();
4544
46 m_source.reset(new MockSource);45 m_source.reset(new MockSource);
47 m_model.reset(new MutableModel);46 m_controller.reset(new Controller(m_source));
48 m_controller.reset(new Controller(m_model, m_source));
49 }47 }
5048
51 void TearDown()49 void TearDown()
52 {50 {
53 m_controller.reset();51 m_controller.reset();
54 m_model.reset();
55 m_source.reset();52 m_source.reset();
5653
57 super::TearDown();54 super::TearDown();
@@ -102,22 +99,29 @@
102 auto t = std::make_shared<Transfer>();99 auto t = std::make_shared<Transfer>();
103 t->state = transfer.state;100 t->state = transfer.state;
104 t->id = transfer.id;101 t->id = transfer.id;
105 m_model->add(t);102 m_source->m_model->add(t);
106 }103 }
107104
108 // make sure all the transfers made it into the model105 // make sure all the transfers made it into the model
109 auto ids = m_model->get_ids();106 EXPECT_EQ(G_N_ELEMENTS(transfers), m_controller->size());
110 EXPECT_EQ(G_N_ELEMENTS(transfers), ids.size());
111 for (const auto& transfer : transfers)107 for (const auto& transfer : transfers)
112 EXPECT_EQ(1, ids.count(transfer.id));108 {
109 EXPECT_EQ(1, m_controller->count(transfer.id));
110 EXPECT_CALL(*m_source, clear(transfer.id)).Times(transfer.can_clear?1:0);
111 }
113112
114 // call clear-all113 // call clear-all
115 m_controller->clear_all();114 m_controller->clear_all();
116115
117 // make sure all the clearable transfers are gone116 // make sure all the clearable transfers are gone from controler and source
118 ids = m_model->get_ids();117 auto source_ids = m_source->get_model()->get_ids();
118
119 for (const auto& transfer : transfers)119 for (const auto& transfer : transfers)
120 EXPECT_EQ((transfer.can_clear ? 0 : 1), ids.count(transfer.id));120 {
121 int expect_count = (transfer.can_clear ? 0 : 1);
122 EXPECT_EQ(source_ids.count(transfer.id), expect_count);
123 EXPECT_EQ(m_controller->count(transfer.id), expect_count);
124 }
121}125}
122126
123/**127/**
@@ -145,7 +149,7 @@
145 auto t = std::make_shared<Transfer>();149 auto t = std::make_shared<Transfer>();
146 t->state = transfer.state;150 t->state = transfer.state;
147 t->id = transfer.id;151 t->id = transfer.id;
148 m_model->add(t);152 m_source->m_model->add(t);
149 EXPECT_EQ(transfer.can_pause, t->can_pause());153 EXPECT_EQ(transfer.can_pause, t->can_pause());
150 EXPECT_CALL(*m_source, pause(transfer.id)).Times(transfer.can_pause?1:0);154 EXPECT_CALL(*m_source, pause(transfer.id)).Times(transfer.can_pause?1:0);
151 }155 }
@@ -178,7 +182,7 @@
178 auto t = std::make_shared<Transfer>();182 auto t = std::make_shared<Transfer>();
179 t->state = transfer.state;183 t->state = transfer.state;
180 t->id = transfer.id;184 t->id = transfer.id;
181 m_model->add(t);185 m_source->m_model->add(t);
182 EXPECT_EQ(transfer.can_resume, t->can_resume());186 EXPECT_EQ(transfer.can_resume, t->can_resume());
183 EXPECT_CALL(*m_source, resume(transfer.id)).Times(transfer.can_resume?1:0);187 EXPECT_CALL(*m_source, resume(transfer.id)).Times(transfer.can_resume?1:0);
184 }188 }
@@ -196,7 +200,7 @@
196 auto t = std::make_shared<Transfer>();200 auto t = std::make_shared<Transfer>();
197 t->state = Transfer::QUEUED;201 t->state = Transfer::QUEUED;
198 t->id = id;202 t->id = id;
199 m_model->add(t);203 m_source->m_model->add(t);
200204
201 t->state = Transfer::QUEUED;205 t->state = Transfer::QUEUED;
202 EXPECT_CALL(*m_source, start(id)).Times(1);206 EXPECT_CALL(*m_source, start(id)).Times(1);
@@ -269,7 +273,7 @@
269 auto t = std::make_shared<Transfer>();273 auto t = std::make_shared<Transfer>();
270 t->id = id;274 t->id = id;
271 t->state = Transfer::QUEUED;275 t->state = Transfer::QUEUED;
272 m_model->add(t);276 m_source->m_model->add(t);
273277
274 for (const auto& state : all_states)278 for (const auto& state : all_states)
275 {279 {
@@ -289,7 +293,7 @@
289 auto t = std::make_shared<Transfer>();293 auto t = std::make_shared<Transfer>();
290 t->id = id;294 t->id = id;
291 t->state = Transfer::QUEUED;295 t->state = Transfer::QUEUED;
292 m_model->add(t);296 m_source->m_model->add(t);
293297
294 for (const auto& state : all_states)298 for (const auto& state : all_states)
295 {299 {
@@ -309,7 +313,7 @@
309 auto t = std::make_shared<Transfer>();313 auto t = std::make_shared<Transfer>();
310 t->id = id;314 t->id = id;
311 t->state = Transfer::QUEUED;315 t->state = Transfer::QUEUED;
312 m_model->add(t);316 m_source->m_model->add(t);
313317
314 for (const auto& state : all_states)318 for (const auto& state : all_states)
315 {319 {
@@ -329,7 +333,7 @@
329 auto t = std::make_shared<Transfer>();333 auto t = std::make_shared<Transfer>();
330 t->id = id;334 t->id = id;
331 t->state = Transfer::QUEUED;335 t->state = Transfer::QUEUED;
332 m_model->add(t);336 m_source->m_model->add(t);
333337
334 for (const auto& state : all_states)338 for (const auto& state : all_states)
335 {339 {
336340
=== modified file 'tests/test-multisource.cpp'
--- tests/test-multisource.cpp 2015-08-19 18:01:58 +0000
+++ tests/test-multisource.cpp 2015-08-19 18:01:58 +0000
@@ -40,7 +40,7 @@
40 bool operator==(const Event& that) const { return type==that.type && id==that.id; }40 bool operator==(const Event& that) const { return type==that.type && id==that.id; }
41 };41 };
4242
43 bool model_consists_of(const std::shared_ptr<Model>& model, std::initializer_list<std::shared_ptr<Transfer>> list) const43 bool model_consists_of(const std::shared_ptr<const Model>& model, std::initializer_list<std::shared_ptr<Transfer>> list) const
44 {44 {
45 // test get_all()45 // test get_all()
46 std::vector<std::shared_ptr<Transfer>> transfers(list);46 std::vector<std::shared_ptr<Transfer>> transfers(list);
@@ -82,7 +82,7 @@
82 const Transfer::Id aid {"aid"};82 const Transfer::Id aid {"aid"};
83 auto at = std::make_shared<Transfer>();83 auto at = std::make_shared<Transfer>();
84 at->id = aid;84 at->id = aid;
85 a->get_model()->add(at);85 a->m_model->add(at);
86 expected_events.push_back(Event{Event::ADDED,aid});86 expected_events.push_back(Event{Event::ADDED,aid});
8787
88 // confirm that the multimodel sees the new transfer88 // confirm that the multimodel sees the new transfer
@@ -94,7 +94,7 @@
94 const Transfer::Id bid {"bid"};94 const Transfer::Id bid {"bid"};
95 auto bt = std::make_shared<Transfer>();95 auto bt = std::make_shared<Transfer>();
96 bt->id = bid;96 bt->id = bid;
97 b->get_model()->add(bt);97 b->m_model->add(bt);
98 expected_events.push_back(Event{Event::ADDED,bid});98 expected_events.push_back(Event{Event::ADDED,bid});
9999
100 // confirm that the multimodel sees the new transfer100 // confirm that the multimodel sees the new transfer
@@ -104,20 +104,20 @@
104104
105 // poke transfer 'at'...105 // poke transfer 'at'...
106 at->progress = 50.0;106 at->progress = 50.0;
107 a->get_model()->emit_changed(aid);107 a->m_model->emit_changed(aid);
108 expected_events.push_back(Event{Event::CHANGED,aid});108 expected_events.push_back(Event{Event::CHANGED,aid});
109 EXPECT_EQ(expected_events, events);109 EXPECT_EQ(expected_events, events);
110 EXPECT_TRUE(model_consists_of(multimodel, {at, bt}));110 EXPECT_TRUE(model_consists_of(multimodel, {at, bt}));
111111
112 // remove transfer 'at'...112 // remove transfer 'at'...
113 a->get_model()->remove(aid);113 a->m_model->remove(aid);
114 expected_events.push_back(Event{Event::REMOVED,aid});114 expected_events.push_back(Event{Event::REMOVED,aid});
115 EXPECT_EQ(expected_events, events);115 EXPECT_EQ(expected_events, events);
116 EXPECT_FALSE(a->get_model()->get(aid));116 EXPECT_FALSE(a->get_model()->get(aid));
117 EXPECT_TRUE(model_consists_of(multimodel, {bt}));117 EXPECT_TRUE(model_consists_of(multimodel, {bt}));
118118
119 // remove transfer 'bt'...119 // remove transfer 'bt'...
120 b->get_model()->remove(bid);120 b->m_model->remove(bid);
121 expected_events.push_back(Event{Event::REMOVED,bid});121 expected_events.push_back(Event{Event::REMOVED,bid});
122 EXPECT_EQ(expected_events, events);122 EXPECT_EQ(expected_events, events);
123 EXPECT_FALSE(b->get_model()->get(aid));123 EXPECT_FALSE(b->get_model()->get(aid));
@@ -139,13 +139,13 @@
139 const Transfer::Id aid {"aid"};139 const Transfer::Id aid {"aid"};
140 auto at = std::make_shared<Transfer>();140 auto at = std::make_shared<Transfer>();
141 at->id = aid;141 at->id = aid;
142 a->get_model()->add(at);142 a->m_model->add(at);
143143
144 // add a transfer to the 'b' source...144 // add a transfer to the 'b' source...
145 const Transfer::Id bid {"bid"};145 const Transfer::Id bid {"bid"};
146 auto bt = std::make_shared<Transfer>();146 auto bt = std::make_shared<Transfer>();
147 bt->id = bid;147 bt->id = bid;
148 b->get_model()->add(bt);148 b->m_model->add(bt);
149149
150 // confirm that multisource method calls are delegated to 'a'150 // confirm that multisource method calls are delegated to 'a'
151 EXPECT_CALL(*a, open(aid)); multisource.open(aid);151 EXPECT_CALL(*a, open(aid)); multisource.open(aid);
152152
=== modified file 'tests/test-plugin-source.cpp'
--- tests/test-plugin-source.cpp 2015-08-19 18:01:58 +0000
+++ tests/test-plugin-source.cpp 2015-08-19 18:01:58 +0000
@@ -34,7 +34,6 @@
3434
35 GTestDBus* bus = nullptr;35 GTestDBus* bus = nullptr;
3636
37 std::shared_ptr<MutableModel> m_model;
38 std::shared_ptr<Source> m_source;37 std::shared_ptr<Source> m_source;
39 std::shared_ptr<Controller> m_controller;38 std::shared_ptr<Controller> m_controller;
4039
@@ -44,15 +43,13 @@
4443
45 auto plugin_dir = g_get_current_dir();44 auto plugin_dir = g_get_current_dir();
46 m_source.reset(new PluginSource(plugin_dir));45 m_source.reset(new PluginSource(plugin_dir));
47 m_model = m_source->get_model();46 m_controller.reset(new Controller(m_source));
48 m_controller.reset(new Controller(m_model, m_source));
49 g_clear_pointer(&plugin_dir, g_free);47 g_clear_pointer(&plugin_dir, g_free);
50 }48 }
5149
52 void TearDown()50 void TearDown()
53 {51 {
54 m_controller.reset();52 m_controller.reset();
55 m_model.reset();
56 m_source.reset();53 m_source.reset();
5754
58 super::TearDown();55 super::TearDown();
5956
=== modified file 'tests/test-view-gmenu.cpp'
--- tests/test-view-gmenu.cpp 2015-08-19 18:01:58 +0000
+++ tests/test-view-gmenu.cpp 2015-08-19 18:01:58 +0000
@@ -37,7 +37,6 @@
3737
38 GTestDBus* bus = nullptr;38 GTestDBus* bus = nullptr;
39 std::shared_ptr<MockSource> m_source;39 std::shared_ptr<MockSource> m_source;
40 std::shared_ptr<MutableModel> m_model;
41 std::shared_ptr<MockController> m_controller;40 std::shared_ptr<MockController> m_controller;
42 std::shared_ptr<GMenuView> m_view;41 std::shared_ptr<GMenuView> m_view;
4342
@@ -54,22 +53,21 @@
5453
55 // bring up the source54 // bring up the source
56 m_source.reset(new MockSource);55 m_source.reset(new MockSource);
57 m_model.reset(new MutableModel);
58 std::shared_ptr<Transfer> t;56 std::shared_ptr<Transfer> t;
59 t.reset(new Transfer);57 t.reset(new Transfer);
60 t->id = "a";58 t->id = "a";
61 t->state = Transfer::RUNNING;59 t->state = Transfer::RUNNING;
62 m_model->add(t);60 m_source->m_model->add(t);
63 t.reset(new Transfer);61 t.reset(new Transfer);
64 t->id = "b";62 t->id = "b";
65 t->state = Transfer::PAUSED;63 t->state = Transfer::PAUSED;
66 m_model->add(t);64 m_source->m_model->add(t);
67 t.reset(new Transfer);65 t.reset(new Transfer);
68 t->id = "c";66 t->id = "c";
69 t->state = Transfer::FINISHED;67 t->state = Transfer::FINISHED;
70 m_model->add(t);68 m_source->m_model->add(t);
71 m_controller.reset(new MockController(m_model, m_source));69 m_controller.reset(new MockController(m_source));
72 m_view.reset(new GMenuView(m_model, m_controller));70 m_view.reset(new GMenuView(m_controller));
73 }71 }
7472
75 void TearDown()73 void TearDown()
@@ -77,7 +75,6 @@
77 // empty the source75 // empty the source
78 m_view.reset();76 m_view.reset();
79 m_controller.reset();77 m_controller.reset();
80 m_model.reset();
81 m_source.reset();78 m_source.reset();
8279
83 // bring down the bus80 // bring down the bus
@@ -147,9 +144,9 @@
147 "resume-all",144 "resume-all",
148 "resume-transfer"145 "resume-transfer"
149 };146 };
150 for (const auto& id : m_model->get_ids())147 for (const auto& id : m_source->get_model()->get_ids())
151 expected_actions.insert("transfer-state." + id);148 expected_actions.insert("transfer-state." + id);
152 149
153 auto connection = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);150 auto connection = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
154 auto exported = g_dbus_action_group_get(connection, BUS_NAME, BUS_PATH);151 auto exported = g_dbus_action_group_get(connection, BUS_NAME, BUS_PATH);
155 auto names_strv = g_action_group_list_actions(G_ACTION_GROUP(exported));152 auto names_strv = g_action_group_list_actions(G_ACTION_GROUP(exported));
@@ -205,14 +202,14 @@
205202
206 // try tapping a transfer that can be resumed203 // try tapping a transfer that can be resumed
207 const char* id = "b";204 const char* id = "b";
208 EXPECT_TRUE(m_model->get(id)->can_resume());205 EXPECT_TRUE(m_source->get_model()->get(id)->can_resume());
209 EXPECT_CALL(*m_controller, tap(id)).Times(1);206 EXPECT_CALL(*m_controller, tap(id)).Times(1);
210 g_action_group_activate_action(action_group, "activate-transfer", g_variant_new_string(id));207 g_action_group_activate_action(action_group, "activate-transfer", g_variant_new_string(id));
211 wait_msec();208 wait_msec();
212209
213 // try tapping a transfer that CAN'T be resumed210 // try tapping a transfer that CAN'T be resumed
214 id = "c";211 id = "c";
215 EXPECT_TRUE(!m_model->get(id)->can_resume());212 EXPECT_TRUE(!m_source->get_model()->get(id)->can_resume());
216 EXPECT_CALL(*m_controller, tap(id)).Times(1);213 EXPECT_CALL(*m_controller, tap(id)).Times(1);
217 g_action_group_activate_action(action_group, "activate-transfer", g_variant_new_string(id));214 g_action_group_activate_action(action_group, "activate-transfer", g_variant_new_string(id));
218 wait_msec();215 wait_msec();
@@ -270,7 +267,7 @@
270/***267/***
271****268****
272**** Header269**** Header
273**** 270****
274***/271***/
275272
276namespace273namespace
@@ -352,10 +349,10 @@
352 // Visibility test #1:349 // Visibility test #1:
353 // Change the model to all transfers finished.350 // Change the model to all transfers finished.
354 // Confirm that the header is not visible.351 // Confirm that the header is not visible.
355 for (auto& transfer : m_model->get_all())352 for (auto& transfer : m_source->get_model()->get_all())
356 {353 {
357 transfer->state = Transfer::FINISHED;354 transfer->state = Transfer::FINISHED;
358 m_model->emit_changed(transfer->id);355 m_source->m_model->emit_changed(transfer->id);
359 }356 }
360357
361 wait_msec(200);358 wait_msec(200);
@@ -364,26 +361,26 @@
364 // Visibility test #2:361 // Visibility test #2:
365 // Change the model to all transfers finished except one running.362 // Change the model to all transfers finished except one running.
366 // Confirm that the header is visible.363 // Confirm that the header is visible.
367 auto transfer = m_model->get("a");364 auto transfer = m_source->get_model()->get("a");
368 transfer->state = Transfer::RUNNING;365 transfer->state = Transfer::RUNNING;
369 m_model->emit_changed(transfer->id);366 m_source->m_model->emit_changed(transfer->id);
370 wait_msec(200);367 wait_msec(200);
371 EXPECT_TRUE(is_header_visible(action_group, action_name));368 EXPECT_TRUE(is_header_visible(action_group, action_name));
372369
373 // Visibility test #3:370 // Visibility test #3:
374 // Change the model to all transfers finished except one paused.371 // Change the model to all transfers finished except one paused.
375 // Confirm that the header is visible.372 // Confirm that the header is visible.
376 transfer = m_model->get("a");373 transfer = m_source->get_model()->get("a");
377 transfer->state = Transfer::PAUSED;374 transfer->state = Transfer::PAUSED;
378 m_model->emit_changed(transfer->id);375 m_source->m_model->emit_changed(transfer->id);
379 wait_msec(200);376 wait_msec(200);
380 EXPECT_TRUE(is_header_visible(action_group, action_name));377 EXPECT_TRUE(is_header_visible(action_group, action_name));
381378
382 // Visibility test #4:379 // Visibility test #4:
383 // Remove all the transfers from the menu.380 // Remove all the transfers from the menu.
384 // Confirm that the header is not visible.381 // Confirm that the header is not visible.
385 for (const auto& id : m_model->get_ids())382 for (const auto& id : m_source->get_model()->get_ids())
386 m_model->remove(id);383 m_source->m_model->remove(id);
387 wait_msec(200);384 wait_msec(200);
388 EXPECT_FALSE(is_header_visible(action_group, action_name));385 EXPECT_FALSE(is_header_visible(action_group, action_name));
389386

Subscribers

People subscribed via source and target branches