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

Unified Diff: components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.cc

Issue 1829023002: Add fake for InstanceIDWithSubtype.java, in order to re-use unit test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid2jni
Patch Set: Re-fix FindBugs Created 4 years, 8 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
Index: components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.cc
diff --git a/components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.cc b/components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..206b2900f03ce4bec97065e486b1701cf211968a
--- /dev/null
+++ b/components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.cc
@@ -0,0 +1,30 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.h"
+
+#include "base/android/jni_android.h"
+#include "jni/FakeInstanceIDWithSubtype_jni.h"
+
+using base::android::AttachCurrentThread;
+
+namespace instance_id {
+
+// static
+bool ScopedUseFakeInstanceIDAndroid::RegisterJni(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+ScopedUseFakeInstanceIDAndroid::ScopedUseFakeInstanceIDAndroid() {
+ JNIEnv* env = AttachCurrentThread();
+ previous_value_ =
+ Java_FakeInstanceIDWithSubtype_clearDataAndSetEnabled(env, true);
+}
+
+ScopedUseFakeInstanceIDAndroid::~ScopedUseFakeInstanceIDAndroid() {
+ JNIEnv* env = AttachCurrentThread();
+ Java_FakeInstanceIDWithSubtype_clearDataAndSetEnabled(env, previous_value_);
+}
+
+} // namespace instance_id
« no previous file with comments | « components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.h ('k') | components/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698