Skip to content

Commit 6f540ea

Browse files
authored
Fix tvOS iTests - Use UNITY_TVOS and disable Storage filesystem tests (#597)
Fixes to the Storage, Database, Crashlytics and Messaging tests. These testapps has variable behavior based on the target device, and use `UNITY_IOS` or `UNITY_ANDROID` preprocessors to toggle off certain tests. These preprocessor definitions are automatically defined for us by Unity when building for the applicable platforms. This change adds `UNITY_TVOS` where appropriate and makes it use the same tests & code as `UNITY_IOS`. Additionally the Storage tests that download to disk have been disabled since tvOS does not have a dependable file system to test against.
1 parent 952a3b7 commit 6f540ea

File tree

6 files changed

+40
-31
lines changed

6 files changed

+40
-31
lines changed

auth/testapp/Assets/Firebase/Sample/Auth/UIHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#if UNITY_IOS
15+
#if (UNITY_IOS || UNITY_TVOS)
1616
using UnityEngine.SocialPlatforms.GameCenter;
1717
#endif
1818

@@ -350,7 +350,7 @@ public Task SigninAnonymouslyAsync() {
350350
}
351351

352352
public void AuthenticateToGameCenter() {
353-
#if UNITY_IOS
353+
#if (UNITY_IOS || UNITY_TVOS)
354354
Social.localUser.Authenticate(success => {
355355
Debug.Log("Game Center Initialization Complete - Result: " + success);
356356
});

crashlytics/testapp/Assets/Firebase/Sample/Crashlytics/UIHandlerAutomated.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private bool IsCrashlyticsInitialized() {
9090
bool result = (bool)isInitializedMethodInfo.Invoke(impl, new object[] {});
9191
DebugLog("Crashlytics.impl.isSDKInitialized(): " + result);
9292

93-
#if UNITY_ANDROID || UNITY_IOS
93+
#if (UNITY_IOS || UNITY_TVOS || UNITY_ANDROID)
9494
return result;
9595
#else
9696
// The desktop stub implementation returns false, so expect that.

database/testapp/Assets/Firebase/Sample/Database/UIHandlerAutomated.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public class UIHandlerAutomated : UIHandler {
2424
// Database URL
2525
private string databaseUrl = "REPLACE_WITH_YOUR_DATABASE_URL";
2626

27-
#if !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
27+
#if !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
2828
// Manually create the default app on desktop so that it's possible to specify the database URL.
2929
private FirebaseApp defaultApp;
30-
#endif // !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
30+
#endif // !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
3131

3232
static Thread mainThread = null;
3333

@@ -69,13 +69,13 @@ protected override void Start() {
6969
TestQueryEqualToString,
7070
TestQueryEqualToDouble,
7171
TestQueryEqualToBool,
72-
#if !UNITY_IOS
72+
#if !(UNITY_IOS || UNITY_TVOS)
7373
// TODO(b/129906113) These tests don't work on iOS, and are removed
7474
// until they are fixed.
7575
TestQueryEqualToStringAndKey,
7676
TestQueryEqualToDoubleAndKey,
7777
TestQueryEqualToBoolAndKey,
78-
#endif // !UNITY_IOS
78+
#endif // !(UNITY_IOS || UNITY_TVOS)
7979
TestQueryLimitToFirst,
8080
TestQueryLimitToLast,
8181
TestQueryOrderByChild,
@@ -116,21 +116,21 @@ protected override void Start() {
116116

117117
// Create the default FirebaseApp on non-mobile platforms.
118118
private void CreateDefaultApp() {
119-
#if !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
119+
#if !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
120120
defaultApp = FirebaseApp.Create(new AppOptions { DatabaseUrl = new Uri(databaseUrl) });
121121
if (!loggedOnceCreateDefaultApp) {
122122
DebugLog(String.Format("Default app created with database url {0}",
123123
defaultApp.Options.DatabaseUrl));
124124
loggedOnceCreateDefaultApp = true;
125125
}
126-
#endif // !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
126+
#endif // !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
127127
}
128128

129129
// Remove all reference to the default FirebaseApp.
130130
private void DestroyDefaultApp() {
131-
#if !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
131+
#if !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
132132
defaultApp = null;
133-
#endif // !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
133+
#endif // !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
134134
}
135135

136136
protected override void InitializeFirebase() {
@@ -398,13 +398,13 @@ public AsyncChecks(DatabaseReference reference) {
398398
reference.ChildChanged += childChangedListener;
399399
reference.ChildMoved += childMovedListener;
400400
reference.ChildRemoved += childRemovedListener;
401-
#if (UNITY_IOS || UNITY_ANDROID)
401+
#if (UNITY_IOS || UNITY_TVOS || UNITY_ANDROID)
402402
// The desktop implementation will currently fail if exceptions are thrown in child
403403
reference.ChildAdded += childAddedListenerThrowException;
404404
reference.ChildChanged += childChangedListenerThrowException;
405405
reference.ChildMoved += childMovedListenerThrowException;
406406
reference.ChildRemoved += childRemovedListenerThrowException;
407-
#endif // #if (UNITY_IOS || UNITY_ANDROID)
407+
#endif // #if (UNITY_IOS || UNITY_TVOS || UNITY_ANDROID)
408408
}
409409

410410
public bool AllGood { get; private set; }

messaging/testapp/Assets/Firebase/Sample/Messaging/UIHandlerAutomated.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ protected override void Start() {
3838
Func<Task>[] tests = {
3939
// Disable these tests on desktop, as desktop never receives a token, and so WaitForToken
4040
// (called by all of these tests) stalls forever.
41-
#if (UNITY_IOS || UNITY_ANDROID)
41+
#if (UNITY_IOS || UNITY_TVOS || UNITY_ANDROID)
4242
MakeTest(TestWaitForToken),
43-
#if !UNITY_IOS
43+
#if !(UNITY_IOS || UNITY_TVOS)
4444
// TODO(b/130674454) This test times out on iOS, disabling until fixed.
4545
MakeTest(TestSendPlaintextMessageToDevice),
46-
#endif // !UNITY_IOS
46+
#endif // !(UNITY_IOS || UNITY_TVOS)
4747
MakeTest(TestSendJsonMessageToDevice),
4848
MakeTest(TestSendJsonMessageToSubscribedTopic),
49-
#else // (UNITY_IOS || UNITY_ANDROID)
49+
#else // (UNITY_IOS || UNITY_TVOS || UNITY_ANDROID)
5050
// Run a vacuous test. Should be removed if/when desktop platforms get a real test.
5151
MakeTest(TestDummy),
52-
#endif // (UNITY_IOS || UNITY_ANDROID)
52+
#endif // (UNITY_IOS || UNITY_TVOS || UNITY_ANDROID)
5353
// TODO(varconst): a more involved test to check that resubscribing works
5454
MakeTest(TestGetTokenAsync),
5555
MakeTest(TestDeleteTokenAsync),
@@ -58,18 +58,18 @@ protected override void Start() {
5858
string[] customTests = {
5959
// Disable these tests on desktop, as desktop never receives a token, and so WaitForToken
6060
// (called by all of these tests) stalls forever.
61-
#if (UNITY_IOS || UNITY_ANDROID)
61+
#if (UNITY_IOS || UNITY_TVOS || UNITY_ANDROID)
6262
"TestWaitForToken",
63-
#if !UNITY_IOS
63+
#if !(UNITY_IOS || UNITY_TVOS)
6464
// TODO(b/130674454) This test times out on iOS, disabling until fixed.
6565
"TestSendPlaintextMessageToDevice",
66-
#endif // !UNITY_IOS
66+
#endif // !(UNITY_IOS || UNITY_TVOS)
6767
"TestSendJsonMessageToDevice",
6868
"TestSendJsonMessageToSubscribedTopic",
69-
#else // (UNITY_IOS || UNITY_ANDROID)
69+
#else // #if (UNITY_IOS || UNITY_TVOS || UNITY_ANDROID)
7070
// Run a vacuous test. Should be removed if/when desktop platforms get a real test.
7171
"TestDummy",
72-
#endif // (UNITY_IOS || UNITY_ANDROID)
72+
#endif // (UNITY_IOS || UNITY_TVOS || UNITY_ANDROID)
7373
// TODO(varconst): a more involved test to check that resubscribing works
7474
"TestGetTokenAsync",
7575
"TestDeleteTokenAsync",

scripts/gha/integration_testing/XcodeCapabilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* for reference.
4949
*/
5050

51-
#if UNITY_IOS
51+
#if (UNITY_IOS || UNITY_TVOS)
5252
using System.Collections;
5353
using System.Collections.Generic;
5454
using System.Linq;

storage/testapp/Assets/Firebase/Sample/Storage/UIHandlerAutomated.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ public class UIHandlerAutomated : UIHandler {
1717

1818
private Firebase.Sample.AutomatedTestRunner testRunner;
1919

20-
#if !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
20+
#if !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
2121
// Storage bucket (without the scheme) extracted from MyStorageBucket.
2222
private string storageBucket;
2323
// Manually create the default app on desktop so that it's possible to specify the storage bucket.
2424
private FirebaseApp defaultApp;
25-
#endif // !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
25+
#endif // !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
2626

2727
// Metadata to upload to the test file.
2828
private string METADATA_STRING_NON_CUSTOM_ONLY =
@@ -117,12 +117,18 @@ protected override void Start() {
117117
TestUploadBytesSmallFileThenUpdateMetadata,
118118
TestUploadStreamLargeFile,
119119
TestUploadStreamSmallFile,
120+
#if !(UNITY_TVOS)
121+
// Tests which require file access don't work on tvOS.
120122
TestUploadFromFileLargeFile,
121123
TestUploadFromFileSmallFile,
124+
#endif
122125
TestUploadFromNonExistantFile,
123126
TestUploadBytesWithCancelation,
124127
TestUploadStreamWithCancelation,
128+
#if !(UNITY_TVOS)
129+
// Tests which require file access don't work on tvOS.
125130
TestUploadFromFileWithCancelation,
131+
#endif
126132
TestUploadSmallFileGetDownloadUrl,
127133
TestGetDownloadUrlNonExistantFile,
128134
TestUploadSmallFileGetMetadata,
@@ -137,9 +143,12 @@ protected override void Start() {
137143
TestUploadSmallFileAndDownloadUsingStreamCallback,
138144
TestUploadLargeFileAndDownloadUsingStreamCallback,
139145
TestUploadLargeFileAndDownloadUsingStreamCallbackWithCancelation,
146+
#if !(UNITY_TVOS)
147+
// Tests which require file access don't work on tvOS.
140148
TestUploadSmallFileAndDownloadToFile,
141149
TestUploadLargeFileAndDownloadToFile,
142150
TestUploadLargeFileAndDownloadToFileWithCancelation,
151+
#endif
143152
};
144153

145154
testRunner = AutomatedTestRunner.CreateTestRunner(
@@ -173,22 +182,22 @@ protected override void Start() {
173182

174183
// Create the default FirebaseApp on non-mobile platforms.
175184
private void CreateDefaultApp() {
176-
#if !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
185+
#if !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
177186
defaultApp = FirebaseApp.Create(new AppOptions { StorageBucket = storageBucket });
178187
Debug.Log(String.Format("Default app created with storage bucket {0}",
179188
defaultApp.Options.StorageBucket));
180-
#endif // !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
189+
#endif // !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
181190
}
182191

183192
// Remove all reference to the default FirebaseApp.
184193
private void DestroyDefaultApp() {
185-
#if !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
194+
#if !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
186195
defaultApp = null;
187-
#endif // !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
196+
#endif // !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
188197
}
189198

190199
protected override void InitializeFirebase() {
191-
#if !(UNITY_IOS || UNITY_ANDROID) || UNITY_EDITOR
200+
#if !(UNITY_IOS || UNITY_TVOS || UNITY_ANDROID) || UNITY_EDITOR
192201
storageBucket = (new Uri(MyStorageBucket)).Host;
193202
#endif
194203
CreateDefaultApp();

0 commit comments

Comments
 (0)