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

Side by Side Diff: chrome/app/keystone_glue_unittest.mm

Issue 333049: Make KeystoneGlue less antisocial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/keystone_glue.mm ('k') | chrome/browser/cocoa/about_window_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #import <Foundation/Foundation.h> 5 #import <Foundation/Foundation.h>
6 #import <objc/objc-class.h> 6 #import <objc/objc-class.h>
7 7
8 #import "chrome/app/keystone_glue.h" 8 #import "chrome/app/keystone_glue.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 IMP newInfoImp_ = [[FakeKeystoneGlue class] instanceMethodForSelector:ids]; 143 IMP newInfoImp_ = [[FakeKeystoneGlue class] instanceMethodForSelector:ids];
144 Method infoMethod_ = class_getInstanceMethod([KeystoneGlue class], ids); 144 Method infoMethod_ = class_getInstanceMethod([KeystoneGlue class], ids);
145 method_setImplementation(infoMethod_, newInfoImp_); 145 method_setImplementation(infoMethod_, newInfoImp_);
146 146
147 SEL lks = @selector(loadKeystoneRegistration); 147 SEL lks = @selector(loadKeystoneRegistration);
148 IMP oldLoadImp_ = [[KeystoneGlue class] instanceMethodForSelector:lks]; 148 IMP oldLoadImp_ = [[KeystoneGlue class] instanceMethodForSelector:lks];
149 IMP newLoadImp_ = [[FakeKeystoneGlue class] instanceMethodForSelector:lks]; 149 IMP newLoadImp_ = [[FakeKeystoneGlue class] instanceMethodForSelector:lks];
150 Method loadMethod_ = class_getInstanceMethod([KeystoneGlue class], lks); 150 Method loadMethod_ = class_getInstanceMethod([KeystoneGlue class], lks);
151 method_setImplementation(loadMethod_, newLoadImp_); 151 method_setImplementation(loadMethod_, newLoadImp_);
152 152
153 // Dump any existing KeystoneGlue shared instance so that a new one can be
154 // created with the mocked methods.
155 [KeystoneGlue releaseDefaultKeystoneGlue];
156 KeystoneGlue *glue = [KeystoneGlue defaultKeystoneGlue]; 153 KeystoneGlue *glue = [KeystoneGlue defaultKeystoneGlue];
157 ASSERT_TRUE(glue); 154 ASSERT_TRUE(glue);
158 155
159 // Fix back up the class to the way we found it. 156 // Fix back up the class to the way we found it.
160 method_setImplementation(infoMethod_, oldInfoImp_); 157 method_setImplementation(infoMethod_, oldInfoImp_);
161 method_setImplementation(loadMethod_, oldLoadImp_); 158 method_setImplementation(loadMethod_, oldLoadImp_);
162 [KeystoneGlue releaseDefaultKeystoneGlue];
163 } 159 }
164 160
165 TEST_F(KeystoneGlueTest, BasicUse) { 161 TEST_F(KeystoneGlueTest, BasicUse) {
166 FakeKeystoneGlue* glue = [[[FakeKeystoneGlue alloc] init] autorelease]; 162 FakeKeystoneGlue* glue = [[[FakeKeystoneGlue alloc] init] autorelease];
167 [glue loadParameters]; 163 [glue loadParameters];
168 ASSERT_TRUE([glue dictReadCorrectly]); 164 ASSERT_TRUE([glue dictReadCorrectly]);
169 165
170 // Likely returns NO in the unit test, but call it anyway to make 166 // Likely returns NO in the unit test, but call it anyway to make
171 // sure it doesn't crash. 167 // sure it doesn't crash.
172 [glue loadKeystoneRegistration]; 168 [glue loadKeystoneRegistration];
173 169
174 // Confirm we start up an active timer 170 // Confirm we start up an active timer
175 [glue registerWithKeystone]; 171 [glue registerWithKeystone];
176 ASSERT_TRUE([glue hasATimer]); 172 ASSERT_TRUE([glue hasATimer]);
177 [glue stopTimer]; 173 [glue stopTimer];
178 174
179 // Brief exercise of callbacks 175 // Brief exercise of callbacks
180 [glue addFakeRegistration]; 176 [glue addFakeRegistration];
181 [glue checkForUpdate]; 177 [glue checkForUpdate];
182 [glue installUpdate]; 178 [glue installUpdate];
183 ASSERT_TRUE([glue confirmCallbacks]); 179 ASSERT_TRUE([glue confirmCallbacks]);
184 } 180 }
185 181
186 } // namespace 182 } // namespace
OLDNEW
« no previous file with comments | « chrome/app/keystone_glue.mm ('k') | chrome/browser/cocoa/about_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698