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

Unified Diff: components/gcm_driver/instance_id/instance_id_driver_unittest.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: Address 2nd round review comments 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/instance_id_driver_unittest.cc
diff --git a/components/gcm_driver/instance_id/instance_id_driver_unittest.cc b/components/gcm_driver/instance_id/instance_id_driver_unittest.cc
index 8997296aca9b1dad49e6749524421ca3094672b6..63fba0f57a89fcbddab981cc46e8f805d95522f9 100644
--- a/components/gcm_driver/instance_id/instance_id_driver_unittest.cc
+++ b/components/gcm_driver/instance_id/instance_id_driver_unittest.cc
@@ -17,6 +17,11 @@
#include "components/gcm_driver/instance_id/instance_id.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(OS_ANDROID)
+#include "components/gcm_driver/instance_id/instance_id_android.h"
+#include "components/gcm_driver/instance_id/instance_id_test_utils_android.h"
+#endif // OS_ANDROID
+
namespace instance_id {
namespace {
@@ -52,6 +57,7 @@ class InstanceIDDriverTest : public testing::Test {
// testing::Test:
void SetUp() override;
+ void TearDown() override;
void WaitForAsyncOperation();
@@ -105,10 +111,21 @@ InstanceIDDriverTest::~InstanceIDDriverTest() {
}
void InstanceIDDriverTest::SetUp() {
+#if defined(OS_ANDROID)
+ InstanceIDAndroid::SetBlockOnAsyncTasksForTesting(true);
+ InstanceIDTestUtilsAndroid::ClearDataAndSetUseFakeForTesting(true);
Peter Beverloo 2016/04/18 15:46:36 Would we ever used them separately? Could trigger
johnme 2016/04/19 11:15:43 I made them scoped objects. I left them separate f
+#endif // OS_ANDROID
gcm_driver_.reset(new FakeGCMDriverForInstanceID);
RecreateInstanceIDDriver();
}
+void InstanceIDDriverTest::TearDown() {
+#if defined(OS_ANDROID)
+ InstanceIDTestUtilsAndroid::ClearDataAndSetUseFakeForTesting(false);
+ InstanceIDAndroid::SetBlockOnAsyncTasksForTesting(false);
+#endif // OS_ANDROID
+}
+
void InstanceIDDriverTest::RecreateInstanceIDDriver() {
driver_.reset(new InstanceIDDriver(gcm_driver_.get()));
}

Powered by Google App Engine
This is Rietveld 408576698