OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 IOS_WEB_VIEW_TEST_BOOLEAN_OBSERVER_H_ |
| 6 #define IOS_WEB_VIEW_TEST_BOOLEAN_OBSERVER_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 |
| 10 // Class to observe a boolean KVO compliant property. To use this object, first |
| 11 // create an instance of BooleanObserver and call |setObservedObject:keyPath:|. |
| 12 // After an expected change in the value of |keyPath|, ask for |lastValue| and |
| 13 // compare to the expected value. |
| 14 @interface BooleanObserver : NSObject |
| 15 |
| 16 // The last value of performing |keyPath| on |object| after being notified of a |
| 17 // KVO value change or null if a change has not been observed. |
| 18 @property(nonatomic, nullable, readonly) NSNumber* lastValue; |
| 19 |
| 20 // The |keyPath| of |object| being observed. |
| 21 @property(nonatomic, nullable, readonly) NSString* keyPath; |
| 22 |
| 23 // The current |object| being observed. |
| 24 @property(nonatomic, nullable, readonly, weak) NSObject* object; |
| 25 |
| 26 // Sets the |object| and |keyPath| to observe. Performing |keyPath| on |object| |
| 27 // must return a BOOL value and |keyPath| must be KVO compliant. |
| 28 // If |object| is null and |self.object| is nonnull, |self.object| will stop |
| 29 // being observed. If |object| is nonnull, |keyPath| must be nonnull. |
| 30 - (void)setObservedObject:(nullable NSObject*)object |
| 31 keyPath:(nullable NSString*)keyPath; |
| 32 |
| 33 @end |
| 34 |
| 35 #endif // IOS_WEB_VIEW_TEST_BOOLEAN_OBSERVER_H_ |
OLD | NEW |