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

Side by Side 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: Move FakeInstanceIDWithSubtype to javatests/ 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/gcm_driver/instance_id/instance_id_driver.h" 5 #include "components/gcm_driver/instance_id/instance_id_driver.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" 16 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h"
17 #include "components/gcm_driver/instance_id/instance_id.h" 17 #include "components/gcm_driver/instance_id/instance_id.h"
18 #include "components/gcm_driver/instance_id/instance_id_test_utils_android.h"
Peter Beverloo 2016/04/15 00:00:18 Stick this in the #ifdef too?
johnme 2016/04/15 16:00:43 Done.
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
21 #if defined(OS_ANDROID)
22 #include "components/gcm_driver/instance_id/instance_id_android.h"
23 #endif // OS_ANDROID
24
20 namespace instance_id { 25 namespace instance_id {
21 26
22 namespace { 27 namespace {
23 28
24 const char kTestAppID1[] = "TestApp1"; 29 const char kTestAppID1[] = "TestApp1";
25 const char kTestAppID2[] = "TestApp2"; 30 const char kTestAppID2[] = "TestApp2";
26 const char kAuthorizedEntity1[] = "Sender 1"; 31 const char kAuthorizedEntity1[] = "Sender 1";
27 const char kAuthorizedEntity2[] = "Sender 2"; 32 const char kAuthorizedEntity2[] = "Sender 2";
28 const char kScope1[] = "GCM1"; 33 const char kScope1[] = "GCM1";
29 const char kScope2[] = "FooBar"; 34 const char kScope2[] = "FooBar";
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 103
99 InstanceIDDriverTest::InstanceIDDriverTest() 104 InstanceIDDriverTest::InstanceIDDriverTest()
100 : result_(InstanceID::UNKNOWN_ERROR), 105 : result_(InstanceID::UNKNOWN_ERROR),
101 async_operation_completed_(false) { 106 async_operation_completed_(false) {
102 } 107 }
103 108
104 InstanceIDDriverTest::~InstanceIDDriverTest() { 109 InstanceIDDriverTest::~InstanceIDDriverTest() {
105 } 110 }
106 111
107 void InstanceIDDriverTest::SetUp() { 112 void InstanceIDDriverTest::SetUp() {
113 #if defined(OS_ANDROID)
114 InstanceIDTestUtilsAndroid::ClearDataAndSetUseFakeForTesting(true);
115 InstanceIDAndroid::SetBlockOnAsyncTasksForTesting(true);
Peter Beverloo 2016/04/15 00:00:17 Clean up as part of TearDown? They're statics so t
johnme 2016/04/15 16:00:43 Done (I'd been hoping to avoid the boilerplate, as
116 #endif // OS_ANDROID
108 gcm_driver_.reset(new FakeGCMDriverForInstanceID); 117 gcm_driver_.reset(new FakeGCMDriverForInstanceID);
109 RecreateInstanceIDDriver(); 118 RecreateInstanceIDDriver();
110 } 119 }
111 120
112 void InstanceIDDriverTest::RecreateInstanceIDDriver() { 121 void InstanceIDDriverTest::RecreateInstanceIDDriver() {
113 driver_.reset(new InstanceIDDriver(gcm_driver_.get())); 122 driver_.reset(new InstanceIDDriver(gcm_driver_.get()));
114 } 123 }
115 124
116 void InstanceIDDriverTest::WaitForAsyncOperation() { 125 void InstanceIDDriverTest::WaitForAsyncOperation() {
117 // No need to wait if async operation is not needed. 126 // No need to wait if async operation is not needed.
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 GetToken(instance_id, kAuthorizedEntity1, kScope2, options); 360 GetToken(instance_id, kAuthorizedEntity1, kScope2, options);
352 EXPECT_FALSE(new_token1.empty()); 361 EXPECT_FALSE(new_token1.empty());
353 EXPECT_NE(token1, new_token1); 362 EXPECT_NE(token1, new_token1);
354 363
355 // The other token is not affected by the deletion. 364 // The other token is not affected by the deletion.
356 EXPECT_EQ(token2, 365 EXPECT_EQ(token2,
357 GetToken(instance_id, kAuthorizedEntity2, kScope1, options)); 366 GetToken(instance_id, kAuthorizedEntity2, kScope1, options));
358 } 367 }
359 368
360 } // namespace instance_id 369 } // namespace instance_id
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698