Fjalapeno has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/202806

Change subject: Mar follow on for T95318
......................................................................

Mar follow on for T95318

Do not start manager if we didn't set the API Key
Add unit tests

Change-Id: I29a7ed05c3e8a407de0b39757954633d06656dd3
---
M Wikipedia.xcodeproj/project.pbxproj
A WikipediaUnitTests/BITHockeyManagerWMFExtensionsTests.m
M wikipedia/Categories/BITHockeyManager+WMFExtensions.h
M wikipedia/Categories/BITHockeyManager+WMFExtensions.m
4 files changed, 51 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia 
refs/changes/06/202806/1

diff --git a/Wikipedia.xcodeproj/project.pbxproj 
b/Wikipedia.xcodeproj/project.pbxproj
index fdf2f8c..608cb84 100644
--- a/Wikipedia.xcodeproj/project.pbxproj
+++ b/Wikipedia.xcodeproj/project.pbxproj
@@ -206,6 +206,8 @@
                0EA4402E1AA6281200B09DBA /* NSDateFormatter+WMFExtensions.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 0EA4402D1AA6281200B09DBA /* 
NSDateFormatter+WMFExtensions.m */; };
                0EBC56681AD3656900E82CDD /* WMFAsyncTestCase.m in Sources */ = 
{isa = PBXBuildFile; fileRef = BC7ACB631AB34C9C00791497 /* WMFAsyncTestCase.m 
*/; };
                0EBC567F1AD442CC00E82CDD /* BITHockeyManager+WMFExtensions.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 0EBC567E1AD442CC00E82CDD /* 
BITHockeyManager+WMFExtensions.m */; };
+               0EBC56961AD5B22800E82CDD /* 
BITHockeyManagerWMFExtensionsTests.m in Sources */ = {isa = PBXBuildFile; 
fileRef = 0EBC56951AD5B22800E82CDD /* BITHockeyManagerWMFExtensionsTests.m */; 
};
+               0EBC56971AD5B69300E82CDD /* BITHockeyManager+WMFExtensions.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 0EBC567E1AD442CC00E82CDD /* 
BITHockeyManager+WMFExtensions.m */; };
                701FF5EE601DEA3FCAB7EFD3 /* libPods.a in Frameworks */ = {isa = 
PBXBuildFile; fileRef = D82982ED992F47428037BDF2 /* libPods.a */; };
                954BA118838BF8BA6B01C34A /* libPods-WikipediaUnitTests.a in 
Frameworks */ = {isa = PBXBuildFile; fileRef = 8CE61C6963F825760822A28A /* 
libPods-WikipediaUnitTests.a */; };
                BC0FED621AAA0263002488D7 /* WMFCodingStyle.m in Sources */ = 
{isa = PBXBuildFile; fileRef = BC6FEAE01A9B7EFD00A1D890 /* WMFCodingStyle.m */; 
};
@@ -757,6 +759,7 @@
                0EA4402D1AA6281200B09DBA /* NSDateFormatter+WMFExtensions.m */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; name = "NSDateFormatter+WMFExtensions.m"; path = 
"Wikipedia/Categories/NSDateFormatter+WMFExtensions.m"; sourceTree = 
SOURCE_ROOT; };
                0EBC567D1AD442CC00E82CDD /* BITHockeyManager+WMFExtensions.h */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.h; name = "BITHockeyManager+WMFExtensions.h"; path = 
"Wikipedia/Categories/BITHockeyManager+WMFExtensions.h"; sourceTree = 
SOURCE_ROOT; };
                0EBC567E1AD442CC00E82CDD /* BITHockeyManager+WMFExtensions.m */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; name = "BITHockeyManager+WMFExtensions.m"; path = 
"Wikipedia/Categories/BITHockeyManager+WMFExtensions.m"; sourceTree = 
SOURCE_ROOT; };
+               0EBC56951AD5B22800E82CDD /* 
BITHockeyManagerWMFExtensionsTests.m */ = {isa = PBXFileReference; fileEncoding 
= 4; lastKnownFileType = sourcecode.c.objc; path = 
BITHockeyManagerWMFExtensionsTests.m; sourceTree = "<group>"; };
                17A2F22335C5256576CEDBDD /* 
Pods-WikipediaUnitTests.release.xcconfig */ = {isa = PBXFileReference; 
includeInIndex = 1; lastKnownFileType = text.xcconfig; name = 
"Pods-WikipediaUnitTests.release.xcconfig"; path = "Pods/Target Support 
Files/Pods-WikipediaUnitTests/Pods-WikipediaUnitTests.release.xcconfig"; 
sourceTree = "<group>"; };
                1BC5FB470144D2C10C55A037 /* 
Pods-WikipediaUnitTests.alpha.xcconfig */ = {isa = PBXFileReference; 
includeInIndex = 1; lastKnownFileType = text.xcconfig; name = 
"Pods-WikipediaUnitTests.alpha.xcconfig"; path = "Pods/Target Support 
Files/Pods-WikipediaUnitTests/Pods-WikipediaUnitTests.alpha.xcconfig"; 
sourceTree = "<group>"; };
                357504E50DA104E39C6ACFEB /* Pods.release.xcconfig */ = {isa = 
PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = 
Pods.release.xcconfig; path = "Pods/Target Support 
Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
@@ -2105,6 +2108,7 @@
                                BCA9575C1ABE473800B62AE8 /* 
OldDataSchemaMigratorTests.m */,
                                BC31B2511AB1D9DC008138CA /* 
WMFImageInfoControllerTests.m */,
                                BCE912BC1ACC629B00B74B42 /* 
NSIndexSet+BKReduceTests.m */,
+                               0EBC56951AD5B22800E82CDD /* 
BITHockeyManagerWMFExtensionsTests.m */,
                        );
                        path = WikipediaUnitTests;
                        sourceTree = "<group>";
@@ -2933,6 +2937,7 @@
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               0EBC56971AD5B69300E82CDD /* 
BITHockeyManager+WMFExtensions.m in Sources */,
                                BC2375C11ABB14CC00B0BAA8 /* 
WMFArticleImageInjectionTests.m in Sources */,
                                043B6E8F1ACDE0CF0005C60B /* 
NSAttributedString+WMFSavedPagesAttributedStrings.m in Sources */,
                                BCDB75C41AB0E8300005593F /* 
WMFSubstringUtilsTests.m in Sources */,
@@ -2970,6 +2975,7 @@
                                BCA6765A1AC0600500A16160 /* 
MWKDataStore+TemporaryDataStore.m in Sources */,
                                04F122671ACB818F002FC3B5 /* 
NSString+FormattedAttributedString.m in Sources */,
                                BC0FED711AAA026C002488D7 /* 
WMFJoinedPropertyParametersTests.m in Sources */,
+                               0EBC56961AD5B22800E82CDD /* 
BITHockeyManagerWMFExtensionsTests.m in Sources */,
                                BC0FED6A1AAA0268002488D7 /* 
MWKDataStorePathTests.m in Sources */,
                                BC0FED761AAA026C002488D7 /* 
NSString+WMFHTMLParsingTests.m in Sources */,
                                BCA676571AC05FE200A16160 /* 
XCTestCase+WMFBundleConvenience.m in Sources */,
diff --git a/WikipediaUnitTests/BITHockeyManagerWMFExtensionsTests.m 
b/WikipediaUnitTests/BITHockeyManagerWMFExtensionsTests.m
new file mode 100644
index 0000000..11b7093
--- /dev/null
+++ b/WikipediaUnitTests/BITHockeyManagerWMFExtensionsTests.m
@@ -0,0 +1,33 @@
+
+#define HC_SHORTHAND 1
+#define MOCKITO_SHORTHAND 1
+
+#import <XCTest/XCTest.h>
+#import <OCHamcrest/OCHamcrest.h>
+
+#import "BITHockeyManager+WMFExtensions.h"
+
+
+@interface BITHockeyManagerWMFExtensionsTests : XCTestCase
+
+@end
+
+
+@implementation BITHockeyManagerWMFExtensionsTests
+
+- (void)testKnownBundleID{
+
+    BOOL success = [[BITHockeyManager sharedHockeyManager] 
wmf_setAPIKeyForBundleID:@"org.wikimedia.wikipedia.tfalpha"];
+    assertThat(@(success), is(isTrue()));
+}
+
+
+- (void)testUnknownBundleID{
+    
+    BOOL success = [[BITHockeyManager sharedHockeyManager] 
wmf_setAPIKeyForBundleID:@"org.wikimedia.wikipedia.garbage"];
+    assertThat(@(success), is(isFalse()));
+}
+
+
+
+@end
\ No newline at end of file
diff --git a/wikipedia/Categories/BITHockeyManager+WMFExtensions.h 
b/wikipedia/Categories/BITHockeyManager+WMFExtensions.h
index 1fc07a1..b5b9b55 100644
--- a/wikipedia/Categories/BITHockeyManager+WMFExtensions.h
+++ b/wikipedia/Categories/BITHockeyManager+WMFExtensions.h
@@ -14,8 +14,10 @@
  *  Set the Hockey API Key based on a bundle ID
  *
  *  @param bundleID The bundle ID to map to an API Key
+ *
+ *  @return YES if successful, otherwise NO
  */
-- (void)wmf_setAPIKeyForBundleID:(NSString*)bundleID;
+- (BOOL)wmf_setAPIKeyForBundleID:(NSString*)bundleID;
 
 /**
  *  Configure the alert to be displayed when a user is prompeted to send a 
crash report
diff --git a/wikipedia/Categories/BITHockeyManager+WMFExtensions.m 
b/wikipedia/Categories/BITHockeyManager+WMFExtensions.m
index 18493ab..8ddde14 100644
--- a/wikipedia/Categories/BITHockeyManager+WMFExtensions.m
+++ b/wikipedia/Categories/BITHockeyManager+WMFExtensions.m
@@ -45,21 +45,23 @@
 - (void)wmf_setupAndStart {
     NSString* bundleID = [WikipediaAppUtils bundleID];
 
-    [[BITHockeyManager sharedHockeyManager] wmf_setAPIKeyForBundleID:bundleID];
+    if ([[BITHockeyManager sharedHockeyManager] 
wmf_setAPIKeyForBundleID:bundleID]) {
+        [[BITHockeyManager sharedHockeyManager] startManager];
 
-    [[BITHockeyManager sharedHockeyManager] startManager];
+        [[BITHockeyManager sharedHockeyManager].authenticator 
authenticateInstallation];
 
-    [[BITHockeyManager sharedHockeyManager].authenticator 
authenticateInstallation];
-
-    [[BITHockeyManager sharedHockeyManager] wmf_setupCrashNotificationAlert];
+        [[BITHockeyManager sharedHockeyManager] 
wmf_setupCrashNotificationAlert];
+    }
 }
 
-- (void)wmf_setAPIKeyForBundleID:(NSString*)bundleID {
+- (BOOL)wmf_setAPIKeyForBundleID:(NSString*)bundleID {
     NSString* crashReportingAppID = [[self class] 
crashReportingIDFor:bundleID];
     if (!crashReportingAppID) {
-        return;
+        return NO;
     }
     [[BITHockeyManager sharedHockeyManager] 
configureWithIdentifier:crashReportingAppID];
+
+    return YES;
 }
 
 - (void)wmf_setupCrashNotificationAlert {

-- 
To view, visit https://gerrit.wikimedia.org/r/202806
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I29a7ed05c3e8a407de0b39757954633d06656dd3
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Fjalapeno <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to