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

Unified Diff: ios/web/alloc_with_zone_interceptor_unittest.mm

Issue 1043263003: Implemented AddAllocWithZoneMethod to override allocWithZone: on demand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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: ios/web/alloc_with_zone_interceptor_unittest.mm
diff --git a/ios/web/alloc_with_zone_interceptor_unittest.mm b/ios/web/alloc_with_zone_interceptor_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7b4a1953067fbada6d29c2dd3bb737828e24a5b6
--- /dev/null
+++ b/ios/web/alloc_with_zone_interceptor_unittest.mm
@@ -0,0 +1,36 @@
+// Copyright 2015 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.
+
+#import "ios/web/alloc_with_zone_interceptor.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest_mac.h"
+#include "testing/platform_test.h"
+
+// Testable class to test web::AddAllocWithZoneMethod.
+@interface CRBTestAlloc : NSObject
+@end
+@implementation CRBTestAlloc
+@end
+
+namespace web {
+namespace {
+
+// Test class for alloc_with_zone_interceptor functions.
shreyasv1 2015/04/08 22:36:20 Wording NIT: This is actually a Test Fixture.
Eugene But (OOO till 7-30) 2015/04/08 23:02:12 Done.
+typedef PlatformTest AllocWithZoneInterceptorTest;
+
+// Tests that AddAllocWithZoneMethod delegates allocation to the caller.
+TEST_F(AllocWithZoneInterceptorTest, AddAllocWithZoneMethod) {
+ NSString* const kResult = @"test-result";
+ NSZone* const kZone = NSDefaultMallocZone();
shreyasv1 2015/04/08 22:36:20 Optional: Given that NSDefaultMallocZone returns t
Eugene But (OOO till 7-30) 2015/04/08 23:02:12 I have kResult, having kZone seems consistent.
+ AddAllocWithZoneMethod([CRBTestAlloc class], ^id(Class klass, NSZone* zone) {
+ EXPECT_EQ([CRBTestAlloc class], klass);
+ EXPECT_EQ(kZone, zone);
+ return kResult;
+ });
+ EXPECT_NSEQ(kResult, [CRBTestAlloc allocWithZone:kZone]);
+}
+
+} // namespace
+} // namespace web

Powered by Google App Engine
This is Rietveld 408576698