Skip to content

Commit

Permalink
[Rollouts] Add integration test app (#12239)
Browse files Browse the repository at this point in the history
  • Loading branch information
themiswang committed Jan 23, 2024
1 parent 7c2ac50 commit a57c4e9
Show file tree
Hide file tree
Showing 12 changed files with 1,377 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Crashlytics/Crashlytics/FIRCrashlytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#if SWIFT_PACKAGE
@import FirebaseCrashlyticsSwift;
#else // Swift Package Manager
#import "FirebaseCrashlytics/FirebaseCrashlytics-Swift.h"
#import <FirebaseCrashlytics/FirebaseCrashlytics-Swift.h>
#endif // Cocoapod

#if TARGET_OS_IPHONE
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import SwiftUI

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation
import SwiftUI

struct ContentView: View {
var body: some View {
CrashButtonView()
.padding()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import FirebaseCrashlytics
import Foundation
import SwiftUI

struct ContentView: View {
var body: some View {
CrashButtonView()
.padding()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation
import SwiftUI

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
51 changes: 51 additions & 0 deletions FirebaseRemoteConfig/Tests/FeatureRolloutsTestApp/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

def shared_pods
pod 'FirebaseCore', :path => '../../../'
pod 'FirebaseInstallations', :path => '../../../'
pod 'FirebaseCoreInternal', :path => '../../../'
pod 'FirebaseCoreExtension', :path => '../../../'
pod 'FirebaseRemoteConfigInterop', :path => '../../../'
end

target 'FeatureRolloutsTestApp_iOS' do
platform :ios, '11.0'

# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

shared_pods
end

target 'FeatureRolloutsTestApp_Crashlytics_iOS' do
platform :ios, '11.0'

# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

shared_pods
pod 'FirebaseCrashlytics', :path => '../../../'
end

target 'FeatureRolloutsTestApp_RemoteConfig_iOS' do
platform :ios, '11.0'

# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

shared_pods
pod 'FirebaseRemoteConfig', :path => '../../../'
end

target 'FeatureRolloutsTestApp_CrashlyticsRemoteConfig_iOS' do
platform :ios, '11.0'

# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

shared_pods
pod 'FirebaseCrashlytics', :path => '../../../'
pod 'FirebaseRemoteConfig', :path => '../../../'
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import FirebaseCrashlytics
import Foundation
import SwiftUI

struct CrashButtonView: View {
var body: some View {
var counter = 0

NavigationView {
VStack(
alignment: .leading,
spacing: 10
) {
Button(action: {
Crashlytics.crashlytics().setUserID("ThisIsABot")
}) {
Text("Set User Id")
}

Button(action: {
assertionFailure("Throw a Crash")
}) {
Text("Crash")
}

Button(action: {
Crashlytics.crashlytics().record(error: NSError(
domain: "This is a test non-fatal",
code: 400
))
}) {
Text("Record Non-fatal event")
}

Button(action: {
Crashlytics.crashlytics().setCustomValue(counter, forKey: "counter " + String(counter))
let i = counter
counter = i + 1
}) {
Text("Set custom key")
}
}
.navigationTitle("Crashlytics Example")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import FirebaseCore
import SwiftUI

@main
struct FeatureRolloutsTestAppApp: App {
init() {
FirebaseApp.configure()
}

var body: some Scene {
WindowGroup {
ContentView()
}
}
}
58 changes: 58 additions & 0 deletions FirebaseRemoteConfig/generate_featureRolloutsTestApp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

readonly DIR="$( git rev-parse --show-toplevel )"

#
# This script attempts to copy the Google Services file from google3. If you are not a Google Employee, it will fail, so we'd recommend you create your own Firebase App and place the Google Services file in Tests/TestApp/Shared
#

echoColor() {
COLOR='\033[0;35m'
NC='\033[0m'
printf "${COLOR}$1${NC}\n"
}

echoRed() {
COLOR='\033[0;31m'
NC='\033[0m'
printf "${COLOR}$1${NC}\n"
}

echoColor "Generating Firebase Remote Config Feature Rolouts Test App"
echoColor "Copying GoogleService-Info.plist from google3. Checking gcert status"
if gcertstatus; then
G3Path="/google/src/files/head/depot/google3/third_party/firebase/ios/Secrets/RemoteConfig/FeatureRollouts/GoogleService-Info.plist"
Dest="$DIR/FirebaseRemoteConfig/Tests/FeatureRolloutsTestApp/Shared"
cp $G3Path $Dest
echoColor "Copied $G3Path to $Dest"
else
echoRed "gcert token is not valid. If you are a Google Employee, run 'gcert', and then repeat this command. Non-Google employees will need to download a GoogleService-Info.plist and place it in $DIR/FirebaseRemoteConfig/Tests/FeatureRolloutsTestApp"
fi


echoColor "Running 'pod install'"
cd $DIR/FirebaseRemoteConfig/Tests/FeatureRolloutsTestApp
pod install

# Upon a `pod install`, Crashlytics will copy these files at the root directory
# due to a funky interaction with its cocoapod. This line deletes these extra
# copies of the files as they should only live in Crashlytics/
rm -f $DIR/run $DIR/upload-symbols

open *.xcworkspace

1 change: 1 addition & 0 deletions FirebaseSessions/Tests/TestApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def shared_pods
pod 'FirebaseCoreInternal', :path => '../../../'
pod 'FirebaseCoreExtension', :path => '../../../'
pod 'FirebaseSessions', :path => '../../../'
pod 'FirebaseRemoteConfigInterop', :path => '../../../'
end

target 'AppQualityDevApp_iOS' do
Expand Down

0 comments on commit a57c4e9

Please sign in to comment.