Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chromeos/dbus/fake_upstart_client.cc

Issue 2858353002: MediaPerceptionPrivate API impl and testing. (Closed)
Patch Set: Addressed comments and all tests passing. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/dbus/fake_upstart_client.h" 5 #include "chromeos/dbus/fake_upstart_client.h"
6 6
7 #include "chromeos/dbus/dbus_thread_manager.h" 7 #include "chromeos/dbus/dbus_thread_manager.h"
8 #include "chromeos/dbus/fake_auth_policy_client.h" 8 #include "chromeos/dbus/fake_auth_policy_client.h"
9 #include "chromeos/dbus/fake_media_analytics_client.h" 9 #include "chromeos/dbus/fake_media_analytics_client.h"
10 10
11 namespace chromeos { 11 namespace chromeos {
12 12
13 FakeUpstartClient::FakeUpstartClient() {} 13 FakeUpstartClient::FakeUpstartClient()
14 : start_media_analytics_will_succeed_(true) {}
14 15
15 FakeUpstartClient::~FakeUpstartClient() {} 16 FakeUpstartClient::~FakeUpstartClient() {}
16 17
17 void FakeUpstartClient::Init(dbus::Bus* bus) {} 18 void FakeUpstartClient::Init(dbus::Bus* bus) {}
18 19
19 void FakeUpstartClient::StartAuthPolicyService() { 20 void FakeUpstartClient::StartAuthPolicyService() {
20 static_cast<FakeAuthPolicyClient*>( 21 static_cast<FakeAuthPolicyClient*>(
21 DBusThreadManager::Get()->GetAuthPolicyClient()) 22 DBusThreadManager::Get()->GetAuthPolicyClient())
22 ->set_started(true); 23 ->set_started(true);
23 } 24 }
24 25
25 void FakeUpstartClient::RestartAuthPolicyService() { 26 void FakeUpstartClient::RestartAuthPolicyService() {
26 FakeAuthPolicyClient* authpolicy_client = static_cast<FakeAuthPolicyClient*>( 27 FakeAuthPolicyClient* authpolicy_client = static_cast<FakeAuthPolicyClient*>(
27 DBusThreadManager::Get()->GetAuthPolicyClient()); 28 DBusThreadManager::Get()->GetAuthPolicyClient());
28 DLOG_IF(WARNING, !authpolicy_client->started()) 29 DLOG_IF(WARNING, !authpolicy_client->started())
29 << "Trying to restart authpolicyd which is not started"; 30 << "Trying to restart authpolicyd which is not started";
30 authpolicy_client->set_started(true); 31 authpolicy_client->set_started(true);
31 } 32 }
32 33
34 void FakeUpstartClient::SetStartMediaAnalyticsWillSucceed(bool will_succeed) {
35 start_media_analytics_will_succeed_ = will_succeed;
36 }
37
33 void FakeUpstartClient::StartMediaAnalytics(const UpstartCallback& callback) { 38 void FakeUpstartClient::StartMediaAnalytics(const UpstartCallback& callback) {
39 if (!start_media_analytics_will_succeed_) {
40 callback.Run(false);
41 return;
42 }
34 FakeMediaAnalyticsClient* media_analytics_client = 43 FakeMediaAnalyticsClient* media_analytics_client =
35 static_cast<FakeMediaAnalyticsClient*>( 44 static_cast<FakeMediaAnalyticsClient*>(
36 DBusThreadManager::Get()->GetMediaAnalyticsClient()); 45 DBusThreadManager::Get()->GetMediaAnalyticsClient());
37 DLOG_IF(WARNING, media_analytics_client->process_running()) 46 DLOG_IF(WARNING, media_analytics_client->process_running())
38 << "Trying to start media analytics which is already started."; 47 << "Trying to start media analytics which is already started.";
39 media_analytics_client->set_process_running(true); 48 media_analytics_client->set_process_running(true);
40 callback.Run(true); 49 callback.Run(true);
41 } 50 }
42 51
43 void FakeUpstartClient::StopMediaAnalytics() { 52 void FakeUpstartClient::StopMediaAnalytics() {
44 FakeMediaAnalyticsClient* media_analytics_client = 53 FakeMediaAnalyticsClient* media_analytics_client =
45 static_cast<FakeMediaAnalyticsClient*>( 54 static_cast<FakeMediaAnalyticsClient*>(
46 DBusThreadManager::Get()->GetMediaAnalyticsClient()); 55 DBusThreadManager::Get()->GetMediaAnalyticsClient());
47 DLOG_IF(WARNING, !media_analytics_client->process_running()) 56 DLOG_IF(WARNING, !media_analytics_client->process_running())
48 << "Trying to stop media analytics which is not started."; 57 << "Trying to stop media analytics which is not started.";
49 media_analytics_client->set_process_running(false); 58 media_analytics_client->set_process_running(false);
50 } 59 }
51 60
52 } // namespace chromeos 61 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698