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

Side by Side Diff: ios/public/test/test_updatable_resource_provider.mm

Issue 1102833003: [iOS] Upstream UpdatableConfig test provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « ios/public/test/test_updatable_resource_provider.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #import "ios/public/test/test_updatable_resource_provider.h"
6
7 #include "base/logging.h"
8 #include "base/mac/scoped_nsobject.h"
9
10 #pragma mark - TestUpdatabeResourceDescriptor
11
12 // Dummy UpdatableResourceDescriptorBridge implementation.
13 @interface TestUpdatabeResourceDescriptor
14 : NSObject<UpdatableResourceDescriptorBridge>
15 @property(nonatomic, readonly) NSURL* updateURL;
16 @property(nonatomic, copy) NSString* applicationIdentifier;
17 @property(nonatomic, copy) NSString* applicationVersion;
18 @property(nonatomic, copy) NSString* bundleResourcePath;
19 @property(nonatomic, copy) NSString* updateResourcePath;
20 @end
21
22 @implementation TestUpdatabeResourceDescriptor
23 @synthesize updateURL;
24 @synthesize applicationIdentifier;
25 @synthesize applicationVersion;
26 @synthesize bundleResourcePath;
27 @synthesize updateResourcePath;
28
29 - (void)updateCheckDidFinishWithSuccess:(BOOL)wasSuccessful {
30 }
31
32 - (NSString*)resourcePath {
33 return nil;
34 }
35 @end
36
37 #pragma mark - TestUpdatableResource
38
39 // Dummy UpdatableResourceDescriptorBridge implementation that simply loads data
40 // from the specified plist file.
41 @interface TestUpdatableResource : NSObject<UpdatableResourceBridge>
42 @property(nonatomic, readonly) id<UpdatableResourceDescriptorBridge> descriptor;
43 - (instancetype)initWithDelegate:(id<UpdatableResourceDelegate>)delegate
44 plist:(NSString*)resource_identifier
45 NS_DESIGNATED_INITIALIZER;
46 @end
47
48 @implementation TestUpdatableResource {
49 base::scoped_nsprotocol<id<UpdatableResourceDelegate>> _delegate;
50 base::scoped_nsprotocol<id<UpdatableResourceDescriptorBridge>> _descriptor;
51 }
52
53 - (instancetype)initWithDelegate:(id<UpdatableResourceDelegate>)delegate
54 plist:(NSString*)resourceIdentifier {
55 if (self = [super init]) {
56 _delegate.reset([delegate retain]);
57 _descriptor.reset([[TestUpdatabeResourceDescriptor alloc] init]);
58 DCHECK([resourceIdentifier hasSuffix:@".plist"])
59 << "TestUpdatableResource supports only the plist format";
60 [_descriptor setBundleResourcePath:resourceIdentifier];
61 }
62 return self;
63 }
64
65 - (id<UpdatableResourceDescriptorBridge>)descriptor {
66 return _descriptor.get();
67 }
68
69 - (id<UpdatableResourceDelegate>)delegate {
70 return _delegate;
71 }
72
73 - (NSDictionary*)resourceData {
74 return [NSDictionary
75 dictionaryWithContentsOfFile:[_descriptor bundleResourcePath]];
76 }
77 - (void)loadDefaults {
78 [_delegate loadDefaults:self];
79 }
80
81 @end
82
83 #pragma mark - TestUpdatableResourceProvider
84
85 namespace ios {
86
87 NSString* TestUpdatableResourceProvider::GetUpdateNotificationName() {
88 return @"ResourceUpdatedTest";
89 }
90
91 id<UpdatableResourceBridge>
92 TestUpdatableResourceProvider::CreateUpdatableResource(
93 NSString* resource_identifier,
94 id<UpdatableResourceDelegate> delegate) {
95 NSString* path =
96 [NSString stringWithFormat:@"%@/gm-config/ANY/%@",
97 [[NSBundle mainBundle] resourcePath],
98 resource_identifier];
99 return [[TestUpdatableResource alloc] initWithDelegate:delegate plist:path];
100 }
101
102 } // namespace ios
OLDNEW
« no previous file with comments | « ios/public/test/test_updatable_resource_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698