OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_TEST_BASE_SCOPED_BUNDLE_SWIZZLER_MAC_H_ |
| 6 #define CHROME_TEST_BASE_SCOPED_BUNDLE_SWIZZLER_MAC_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 |
| 11 namespace base { |
| 12 namespace mac { |
| 13 class ScopedObjCClassSwizzler; |
| 14 } // namespace mac |
| 15 } // namespace base |
| 16 |
| 17 // Within a given scope, swizzles the implementation of +[NSBundle mainBundle] |
| 18 // to return a partial mock of the original bundle. This partial mock has a |
| 19 // custom bundle identifier. |
| 20 // Since this class swizzles a class method, it doesn't make sense to have more |
| 21 // than one instance of this class in existence at the same time. |
| 22 // The primary purpose of this class is to stub out the behavior of NSBundle for |
| 23 // AppKit, which makes assumptions about the functionality of +[NSBundle |
| 24 // mainBundle]. Code in Chrome should not require the use of this method, since |
| 25 // the NSBundle is always accessed through bundle_locations.h, and that NSBundle |
| 26 // can be directly stubbed. |
| 27 class ScopedBundleSwizzlerMac { |
| 28 public: |
| 29 ScopedBundleSwizzlerMac(); |
| 30 ~ScopedBundleSwizzlerMac(); |
| 31 |
| 32 private: |
| 33 scoped_ptr<base::mac::ScopedObjCClassSwizzler> class_swizzler_; |
| 34 DISALLOW_COPY_AND_ASSIGN(ScopedBundleSwizzlerMac); |
| 35 }; |
| 36 |
| 37 #endif // CHROME_TEST_BASE_SCOPED_BUNDLE_SWIZZLER_MAC_H_ |
OLD | NEW |