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

Unified Diff: chrome/test/base/scoped_bundle_swizzler_mac.h

Issue 1211213003: mac: Swizzle out +[NSBundle mainBundle] for in process browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from rsesek. Created 5 years, 6 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: chrome/test/base/scoped_bundle_swizzler_mac.h
diff --git a/chrome/test/base/scoped_bundle_swizzler_mac.h b/chrome/test/base/scoped_bundle_swizzler_mac.h
new file mode 100644
index 0000000000000000000000000000000000000000..de84f373e7bcc23a2874b318ec7df9b7052bf9fc
--- /dev/null
+++ b/chrome/test/base/scoped_bundle_swizzler_mac.h
@@ -0,0 +1,32 @@
+// 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.
+
+#ifndef CHROME_TEST_BASE_SCOPED_BUNDLE_SWIZZLER_MAC_H_
+#define CHROME_TEST_BASE_SCOPED_BUNDLE_SWIZZLER_MAC_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+
+namespace base {
+namespace mac {
+class ScopedObjCClassSwizzler;
+} // namespace mac
+} // namespace base
+
+// Within a given scope, swizzles the implementation of +[NSBundle mainBundle]
+// to return a partial mock of the original bundle. This partial mock has a
+// custom bundle identifier.
+// Since this class swizzles a class method, it doesn't make sense to have more
+// than one instance of this class in existence at the same time.
+class ScopedBundleSwizzlerMac {
+ public:
+ ScopedBundleSwizzlerMac();
+ ~ScopedBundleSwizzlerMac();
+
+ private:
+ scoped_ptr<base::mac::ScopedObjCClassSwizzler> class_swizzler_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedBundleSwizzlerMac);
+};
+
+#endif // CHROME_TEST_BASE_SCOPED_BUNDLE_SWIZZLER_MAC_H_

Powered by Google App Engine
This is Rietveld 408576698