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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/public/test/test_updatable_resource_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/public/test/test_updatable_resource_provider.mm
diff --git a/ios/public/test/test_updatable_resource_provider.mm b/ios/public/test/test_updatable_resource_provider.mm
new file mode 100644
index 0000000000000000000000000000000000000000..de8459f2ec0c8636be5d7bd521b67f1c0ec1fa3a
--- /dev/null
+++ b/ios/public/test/test_updatable_resource_provider.mm
@@ -0,0 +1,102 @@
+// 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.
+
+#import "ios/public/test/test_updatable_resource_provider.h"
+
+#include "base/logging.h"
+#include "base/mac/scoped_nsobject.h"
+
+#pragma mark - TestUpdatabeResourceDescriptor
+
+// Dummy UpdatableResourceDescriptorBridge implementation.
+@interface TestUpdatabeResourceDescriptor
+ : NSObject<UpdatableResourceDescriptorBridge>
+@property(nonatomic, readonly) NSURL* updateURL;
+@property(nonatomic, copy) NSString* applicationIdentifier;
+@property(nonatomic, copy) NSString* applicationVersion;
+@property(nonatomic, copy) NSString* bundleResourcePath;
+@property(nonatomic, copy) NSString* updateResourcePath;
+@end
+
+@implementation TestUpdatabeResourceDescriptor
+@synthesize updateURL;
+@synthesize applicationIdentifier;
+@synthesize applicationVersion;
+@synthesize bundleResourcePath;
+@synthesize updateResourcePath;
+
+- (void)updateCheckDidFinishWithSuccess:(BOOL)wasSuccessful {
+}
+
+- (NSString*)resourcePath {
+ return nil;
+}
+@end
+
+#pragma mark - TestUpdatableResource
+
+// Dummy UpdatableResourceDescriptorBridge implementation that simply loads data
+// from the specified plist file.
+@interface TestUpdatableResource : NSObject<UpdatableResourceBridge>
+@property(nonatomic, readonly) id<UpdatableResourceDescriptorBridge> descriptor;
+- (instancetype)initWithDelegate:(id<UpdatableResourceDelegate>)delegate
+ plist:(NSString*)resource_identifier
+ NS_DESIGNATED_INITIALIZER;
+@end
+
+@implementation TestUpdatableResource {
+ base::scoped_nsprotocol<id<UpdatableResourceDelegate>> _delegate;
+ base::scoped_nsprotocol<id<UpdatableResourceDescriptorBridge>> _descriptor;
+}
+
+- (instancetype)initWithDelegate:(id<UpdatableResourceDelegate>)delegate
+ plist:(NSString*)resourceIdentifier {
+ if (self = [super init]) {
+ _delegate.reset([delegate retain]);
+ _descriptor.reset([[TestUpdatabeResourceDescriptor alloc] init]);
+ DCHECK([resourceIdentifier hasSuffix:@".plist"])
+ << "TestUpdatableResource supports only the plist format";
+ [_descriptor setBundleResourcePath:resourceIdentifier];
+ }
+ return self;
+}
+
+- (id<UpdatableResourceDescriptorBridge>)descriptor {
+ return _descriptor.get();
+}
+
+- (id<UpdatableResourceDelegate>)delegate {
+ return _delegate;
+}
+
+- (NSDictionary*)resourceData {
+ return [NSDictionary
+ dictionaryWithContentsOfFile:[_descriptor bundleResourcePath]];
+}
+- (void)loadDefaults {
+ [_delegate loadDefaults:self];
+}
+
+@end
+
+#pragma mark - TestUpdatableResourceProvider
+
+namespace ios {
+
+NSString* TestUpdatableResourceProvider::GetUpdateNotificationName() {
+ return @"ResourceUpdatedTest";
+}
+
+id<UpdatableResourceBridge>
+TestUpdatableResourceProvider::CreateUpdatableResource(
+ NSString* resource_identifier,
+ id<UpdatableResourceDelegate> delegate) {
+ NSString* path =
+ [NSString stringWithFormat:@"%@/gm-config/ANY/%@",
+ [[NSBundle mainBundle] resourcePath],
+ resource_identifier];
+ return [[TestUpdatableResource alloc] initWithDelegate:delegate plist:path];
+}
+
+} // namespace ios
« 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