| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "ios/public/test/test_updatable_resource_provider.h" | 5 #import "ios/public/test/test_updatable_resource_provider.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 | 9 |
| 10 #pragma mark - TestUpdatabeResourceDescriptor | 10 #pragma mark - TestUpdatabeResourceDescriptor |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 #pragma mark - TestUpdatableResource | 37 #pragma mark - TestUpdatableResource |
| 38 | 38 |
| 39 // Dummy UpdatableResourceDescriptorBridge implementation that simply loads data | 39 // Dummy UpdatableResourceDescriptorBridge implementation that simply loads data |
| 40 // from the specified plist file. | 40 // from the specified plist file. |
| 41 @interface TestUpdatableResource : NSObject<UpdatableResourceBridge> | 41 @interface TestUpdatableResource : NSObject<UpdatableResourceBridge> |
| 42 @property(nonatomic, readonly) id<UpdatableResourceDescriptorBridge> descriptor; | 42 @property(nonatomic, readonly) id<UpdatableResourceDescriptorBridge> descriptor; |
| 43 - (instancetype)initWithDelegate:(id<UpdatableResourceDelegate>)delegate | 43 - (instancetype)initWithDelegate:(id<UpdatableResourceDelegate>)delegate |
| 44 plist:(NSString*)resource_identifier | 44 plist:(NSString*)resource_identifier |
| 45 NS_DESIGNATED_INITIALIZER; | 45 NS_DESIGNATED_INITIALIZER; |
| 46 - (instancetype)init NS_UNAVAILABLE; |
| 46 @end | 47 @end |
| 47 | 48 |
| 48 @implementation TestUpdatableResource { | 49 @implementation TestUpdatableResource { |
| 49 base::scoped_nsprotocol<id<UpdatableResourceDelegate>> _delegate; | 50 base::scoped_nsprotocol<id<UpdatableResourceDelegate>> _delegate; |
| 50 base::scoped_nsprotocol<id<UpdatableResourceDescriptorBridge>> _descriptor; | 51 base::scoped_nsprotocol<id<UpdatableResourceDescriptorBridge>> _descriptor; |
| 51 } | 52 } |
| 52 | 53 |
| 53 - (instancetype)initWithDelegate:(id<UpdatableResourceDelegate>)delegate | 54 - (instancetype)initWithDelegate:(id<UpdatableResourceDelegate>)delegate |
| 54 plist:(NSString*)resourceIdentifier { | 55 plist:(NSString*)resourceIdentifier { |
| 55 if (self = [super init]) { | 56 if (self = [super init]) { |
| 56 _delegate.reset([delegate retain]); | 57 _delegate.reset([delegate retain]); |
| 57 _descriptor.reset([[TestUpdatabeResourceDescriptor alloc] init]); | 58 _descriptor.reset([[TestUpdatabeResourceDescriptor alloc] init]); |
| 58 DCHECK([resourceIdentifier hasSuffix:@".plist"]) | 59 DCHECK([resourceIdentifier hasSuffix:@".plist"]) |
| 59 << "TestUpdatableResource supports only the plist format"; | 60 << "TestUpdatableResource supports only the plist format"; |
| 60 [_descriptor setBundleResourcePath:resourceIdentifier]; | 61 [_descriptor setBundleResourcePath:resourceIdentifier]; |
| 61 } | 62 } |
| 62 return self; | 63 return self; |
| 63 } | 64 } |
| 64 | 65 |
| 66 - (instancetype)init { |
| 67 NOTREACHED(); |
| 68 return nil; |
| 69 } |
| 70 |
| 65 - (id<UpdatableResourceDescriptorBridge>)descriptor { | 71 - (id<UpdatableResourceDescriptorBridge>)descriptor { |
| 66 return _descriptor.get(); | 72 return _descriptor.get(); |
| 67 } | 73 } |
| 68 | 74 |
| 69 - (id<UpdatableResourceDelegate>)delegate { | 75 - (id<UpdatableResourceDelegate>)delegate { |
| 70 return _delegate; | 76 return _delegate; |
| 71 } | 77 } |
| 72 | 78 |
| 73 - (NSDictionary*)resourceData { | 79 - (NSDictionary*)resourceData { |
| 74 return [NSDictionary | 80 return [NSDictionary |
| (...skipping 18 matching lines...) Expand all Loading... |
| 93 NSString* resource_identifier, | 99 NSString* resource_identifier, |
| 94 id<UpdatableResourceDelegate> delegate) { | 100 id<UpdatableResourceDelegate> delegate) { |
| 95 NSString* path = | 101 NSString* path = |
| 96 [NSString stringWithFormat:@"%@/gm-config/ANY/%@", | 102 [NSString stringWithFormat:@"%@/gm-config/ANY/%@", |
| 97 [[NSBundle mainBundle] resourcePath], | 103 [[NSBundle mainBundle] resourcePath], |
| 98 resource_identifier]; | 104 resource_identifier]; |
| 99 return [[TestUpdatableResource alloc] initWithDelegate:delegate plist:path]; | 105 return [[TestUpdatableResource alloc] initWithDelegate:delegate plist:path]; |
| 100 } | 106 } |
| 101 | 107 |
| 102 } // namespace ios | 108 } // namespace ios |
| OLD | NEW |