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

Unified Diff: device/wake_lock/wake_lock_provider.cc

Issue 2883903002: Add service unittest for WakeLockServiceImpl. (Closed)
Patch Set: Rename Fake* to *ForTesting Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/wake_lock/wake_lock_provider.h ('k') | device/wake_lock/wake_lock_service_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/wake_lock/wake_lock_provider.cc
diff --git a/device/wake_lock/wake_lock_provider.cc b/device/wake_lock/wake_lock_provider.cc
index bbd4922fd998784cc2f43a77b626944bc547a895..b06208fad7b1756c219c98fce8147d42624af7cf 100644
--- a/device/wake_lock/wake_lock_provider.cc
+++ b/device/wake_lock/wake_lock_provider.cc
@@ -7,10 +7,13 @@
#include <utility>
#include "device/wake_lock/wake_lock_service_impl.h"
+#include "device/wake_lock/wake_lock_service_impl_for_testing.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
namespace device {
+bool WakeLockProvider::is_in_service_unittest_ = false;
+
// static
void WakeLockProvider::Create(
mojom::WakeLockProviderRequest request,
@@ -44,10 +47,18 @@ void WakeLockProvider::GetWakeLockWithoutContext(
mojom::WakeLockReason reason,
const std::string& description,
mojom::WakeLockServiceRequest request) {
- // WakeLockServiceImpl owns itself.
- new WakeLockServiceImpl(std::move(request), type, reason, description,
- WakeLockServiceContext::WakeLockInvalidContextId,
- native_view_getter_, file_task_runner_);
+ if (is_in_service_unittest_) {
+ // Create WakeLockServiceImplForTesting.
+ new WakeLockServiceImplForTesting(
+ std::move(request), type, reason, description,
+ WakeLockServiceContext::WakeLockInvalidContextId, native_view_getter_,
+ file_task_runner_);
+ } else {
+ // WakeLockServiceImpl owns itself.
+ new WakeLockServiceImpl(std::move(request), type, reason, description,
+ WakeLockServiceContext::WakeLockInvalidContextId,
+ native_view_getter_, file_task_runner_);
+ }
}
} // namespace device
« no previous file with comments | « device/wake_lock/wake_lock_provider.h ('k') | device/wake_lock/wake_lock_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698