Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admob/testapp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# AdMob test application.
target 'testapp' do
pod 'Firebase/AdMob', '6.17.0'
pod 'Firebase/AdMob', '6.24.0'
end
2 changes: 1 addition & 1 deletion analytics/testapp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# Analytics test application.
target 'testapp' do
pod 'Firebase/Analytics', '6.17.0'
pod 'Firebase/Analytics', '6.24.0'
end
2 changes: 1 addition & 1 deletion auth/testapp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# Auth test application.
target 'testapp' do
pod 'Firebase/Auth', '6.17.0'
pod 'Firebase/Auth', '6.24.0'
end
2 changes: 1 addition & 1 deletion database/testapp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ else()
"-framework Security"
)
elseif(MSVC)
set(ADDITIONAL_LIBS advapi32 ws2_32 crypt32 iphlpapi psapi userenv)
set(ADDITIONAL_LIBS advapi32 ws2_32 crypt32 iphlpapi psapi userenv shell32)
else()
set(ADDITIONAL_LIBS pthread)
endif()
Expand Down
4 changes: 2 additions & 2 deletions database/testapp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# Firebase Realtime Database test application.
target 'testapp' do
pod 'Firebase/Database', '6.17.0'
pod 'Firebase/Auth', '6.17.0'
pod 'Firebase/Database', '6.24.0'
pod 'Firebase/Auth', '6.24.0'
end
9 changes: 4 additions & 5 deletions demos/TicTacToe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down Expand Up @@ -90,7 +90,6 @@ endif()
if(NOT DEFINED BUILD_ENGINE_DONE) # to test install_test into root project
set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)
set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)

include(CocosBuildSet)
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)
endif()
Expand All @@ -105,8 +104,8 @@ if(APPLE OR WINDOWS)
endif()

# add cross-platforms source files and header files
list(APPEND GAME_SOURCE Classes/AppDelegate.cpp Classes/TicTacToeScene.cpp)
list(APPEND GAME_HEADER Classes/AppDelegate.h Classes/TicTacToeScene.h)
list(APPEND GAME_SOURCE Classes/app_delegate.cc )
list(APPEND GAME_HEADER Classes/app_delegate.h )

if(ANDROID)
# change APP_NAME to the share library name for Android, it's value depend on AndroidManifest.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "AppDelegate.h"
#include "app_delegate.h"

#include "main_menu_scene.h"
#include "tic_tac_toe_scene.h"

#include "MainMenuScene.h"
#include "TicTacToeScene.h"
USING_NS_CC;

// Set based on the image width.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "MainMenuScene.h"
#include "main_menu_scene.h"

#include <regex>

#include "cocos2d.h"
#include "firebase/util.h"
#include "tic_tac_toe_scene.h"
#include "util.h"
#include "TicTacToeScene.h"

static const char* kCreateGameImage = "create_game.png";
static const char* kTextFieldBorderImage = "text_field_border.png";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

#include <string.h>

#include "cocos2d.h"
#include "firebase/auth.h"
#include "firebase/future.h"
#include "firebase/database.h"
#include "cocos2d.h"
#include "firebase/future.h"

using std::to_string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "TicTacToeLayer.h"
#include "tic_tac_toe_layer.h"

USING_NS_CC;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include <string>
#include <unordered_set>

#include "TicTacToeScene.h"
#include "cocos2d.h"
#include "tic_tac_toe_scene.h"
#include "util.h"

using cocos2d::Director;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "TicTacToeScene.h"
#include "tic_tac_toe_scene.h"

using cocos2d::Scene;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#ifndef TICTACTOE_DEMO_CLASSES_TICTACTOE_SCENE_H_
#define TICTACTOE_DEMO_CLASSES_TICTACTOE_SCENE_H_

#include "MainMenuScene.h"
#include "TicTacToeLayer.h"
#include "cocos2d.h"
#include "main_menu_scene.h"
#include "tic_tac_toe_layer.h"
#include "util.h"

class TicTacToe : public cocos2d::Layer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#include "util.h"

#include <Windows.h>
#include <synchapi.h>

#include <random>

// Logs the message passed in to the console.
Expand Down
2 changes: 2 additions & 0 deletions demos/TicTacToe/Classes/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#ifndef TICTACTOE_DEMO_CLASSES_UTIL_H_
#define TICTACTOE_DEMO_CLASSES_UTIL_H_

#include <string>

#include "firebase/future.h"

// inputs: const char* as the message that will be displayed.
Expand Down
2 changes: 1 addition & 1 deletion dynamic_links/testapp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# Dynamic Links test application.
target 'testapp' do
pod 'Firebase/DynamicLinks', '6.17.0'
pod 'Firebase/DynamicLinks', '6.24.0'
end
6 changes: 3 additions & 3 deletions firestore/testapp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# Firebase Firestore test application.
target 'testapp' do
pod 'Firebase/Analytics', '6.18.0'
pod 'Firebase/Firestore', '6.18.0'
pod 'Firebase/Auth', '6.18.0'
pod 'Firebase/Analytics', '6.24.0'
pod 'Firebase/Firestore', '6.24.0'
pod 'Firebase/Auth', '6.24.0'
end
114 changes: 48 additions & 66 deletions firestore/testapp/src/common_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
const int kTimeoutMs = 5000;
const int kSleepMs = 100;

// Wait for a Future to be completed. If the Future returns an error, it will
// be logged.
void Await(const firebase::FutureBase& future, const char* name) {
// Waits for a Future to be completed and returns whether the future has
// completed successfully. If the Future returns an error, it will be logged.
bool Await(const firebase::FutureBase& future, const char* name) {
int remaining_timeout = kTimeoutMs;
while (future.status() == firebase::kFutureStatusPending &&
remaining_timeout > 0) {
Expand All @@ -42,10 +42,13 @@ void Await(const firebase::FutureBase& future, const char* name) {

if (future.status() != firebase::kFutureStatusComplete) {
LogMessage("ERROR: %s returned an invalid result.", name);
return false;
} else if (future.error() != 0) {
LogMessage("ERROR: %s returned error %d: %s", name, future.error(),
future.error_message());
return false;
}
return true;
}

class Countable {
Expand All @@ -65,7 +68,7 @@ class TestEventListener : public Countable,
void OnEvent(const T& value,
const firebase::firestore::Error error) override {
event_count_++;
if (error != firebase::firestore::Ok) {
if (error != firebase::firestore::kOk) {
LogMessage("ERROR: EventListener %s got %d.", name_.c_str(), error);
}
}
Expand Down Expand Up @@ -124,11 +127,11 @@ extern "C" int common_main(int argc, const char* argv[]) {
// Auth caches the previously signed-in user, which can be annoying when
// trying to test for sign-in failures.
auth->SignOut();
auto future_login = auth->SignInAnonymously();
Await(future_login, "Auth sign-in");
auto* future_login_result = future_login.result();
if (future_login_result && *future_login_result) {
const firebase::auth::User* user = *future_login_result;
auto login_future = auth->SignInAnonymously();
Await(login_future, "Auth sign-in");
auto* login_result = login_future.result();
if (login_result && *login_result) {
const firebase::auth::User* user = *login_result;
LogMessage("Signed in as %s user, uid: %s, email: %s.\n",
user->is_anonymous() ? "an anonymous" : "a non-anonymous",
user->uid().c_str(), user->email().c_str());
Expand All @@ -138,7 +141,7 @@ extern "C" int common_main(int argc, const char* argv[]) {

// Note: Auth cannot be deleted while any of the futures issued by it are
// still valid.
future_login.Release();
login_future.Release();

LogMessage("Initialize Firebase Firestore.");

Expand Down Expand Up @@ -170,7 +173,7 @@ extern "C" int common_main(int argc, const char* argv[]) {
}
LogMessage("Successfully initialized Firebase Firestore.");

firestore->set_logging_enabled(true);
firestore->set_log_level(firebase::kLogLevelDebug);

if (firestore->app() != app) {
LogMessage("ERROR: failed to get App the Firestore was created with.");
Expand Down Expand Up @@ -219,28 +222,20 @@ extern "C" int common_main(int argc, const char* argv[]) {
}

LogMessage("Testing Set().");
document.Set(firebase::firestore::MapFieldValue{
{"str", firebase::firestore::FieldValue::FromString("foo")},
{"int", firebase::firestore::FieldValue::FromInteger(123LL)}});
Await(document.SetLastResult(), "document.Set");
if (document.SetLastResult().status() != firebase::kFutureStatusComplete) {
LogMessage("ERROR: failed to write document.");
}
Await(document.Set(firebase::firestore::MapFieldValue{
{"str", firebase::firestore::FieldValue::String("foo")},
{"int", firebase::firestore::FieldValue::Integer(123)}}),
"document.Set");

LogMessage("Testing Update().");
document.Update(firebase::firestore::MapFieldValue{
{"int", firebase::firestore::FieldValue::FromInteger(321LL)}});
Await(document.UpdateLastResult(), "document.Update");
if (document.UpdateLastResult().status() != firebase::kFutureStatusComplete) {
LogMessage("ERROR: failed to write document.");
}
Await(document.Update(firebase::firestore::MapFieldValue{
{"int", firebase::firestore::FieldValue::Integer(321)}}),
"document.Update");

LogMessage("Testing Get().");
document.Get();
Await(document.GetLastResult(), "document.Get");
if (document.GetLastResult().status() == firebase::kFutureStatusComplete) {
const firebase::firestore::DocumentSnapshot* snapshot =
document.GetLastResult().result();
auto doc_future = document.Get();
if (Await(doc_future, "document.Get")) {
const firebase::firestore::DocumentSnapshot* snapshot = doc_future.result();
if (snapshot == nullptr) {
LogMessage("ERROR: failed to read document.");
} else {
Expand All @@ -263,11 +258,7 @@ extern "C" int common_main(int argc, const char* argv[]) {
}

LogMessage("Testing Delete().");
document.Delete();
Await(document.DeleteLastResult(), "document.Delete");
if (document.DeleteLastResult().status() != firebase::kFutureStatusComplete) {
LogMessage("ERROR: failed to delete document.");
}
Await(document.Delete(), "document.Delete");
LogMessage("Tested document operations.");

TestEventListener<firebase::firestore::DocumentSnapshot>
Expand All @@ -282,50 +273,41 @@ extern "C" int common_main(int argc, const char* argv[]) {
firebase::firestore::WriteBatch batch = firestore->batch();
batch.Set(collection.Document("one"),
firebase::firestore::MapFieldValue{
{"str", firebase::firestore::FieldValue::FromString("foo")}});
{"str", firebase::firestore::FieldValue::String("foo")}});
batch.Set(collection.Document("two"),
firebase::firestore::MapFieldValue{
{"int", firebase::firestore::FieldValue::FromInteger(123LL)}});
batch.Commit();
Await(batch.CommitLastResult(), "batch.Commit");
if (batch.CommitLastResult().status() != firebase::kFutureStatusComplete) {
LogMessage("ERROR: failed to write batch.");
}
{"int", firebase::firestore::FieldValue::Integer(123)}});
Await(batch.Commit(), "batch.Commit");
LogMessage("Tested batch write.");

LogMessage("Testing transaction.");
firestore->RunTransaction(
[collection](firebase::firestore::Transaction* transaction,
std::string* error_message) -> firebase::firestore::Error {
transaction->Update(
collection.Document("one"),
firebase::firestore::MapFieldValue{
{"int", firebase::firestore::FieldValue::FromInteger(123LL)}});
transaction->Delete(collection.Document("two"));
transaction->Set(
collection.Document("three"),
firebase::firestore::MapFieldValue{
{"int", firebase::firestore::FieldValue::FromInteger(321LL)}});
return firebase::firestore::Ok;
});
Await(firestore->RunTransactionLastResult(), "firestore.RunTransaction");
if (firestore->RunTransactionLastResult().status() !=
firebase::kFutureStatusComplete) {
LogMessage("ERROR: failed to run transaction.");
}
Await(
firestore->RunTransaction(
[collection](firebase::firestore::Transaction& transaction,
std::string&) -> firebase::firestore::Error {
transaction.Update(
collection.Document("one"),
firebase::firestore::MapFieldValue{
{"int", firebase::firestore::FieldValue::Integer(123)}});
transaction.Delete(collection.Document("two"));
transaction.Set(
collection.Document("three"),
firebase::firestore::MapFieldValue{
{"int", firebase::firestore::FieldValue::Integer(321)}});
return firebase::firestore::kOk;
}),
"firestore.RunTransaction");
LogMessage("Tested transaction.");

LogMessage("Testing query.");
firebase::firestore::Query query =
collection
.WhereGreaterThan("int",
firebase::firestore::FieldValue::FromBoolean(true))
firebase::firestore::FieldValue::Boolean(true))
.Limit(3);
query.Get();
Await(query.GetLastResult(), "query.Get");
if (query.GetLastResult().status() == firebase::kFutureStatusComplete) {
const firebase::firestore::QuerySnapshot* snapshot =
query.GetLastResult().result();
auto query_future = query.Get();
if (Await(query_future, "query.Get")) {
const firebase::firestore::QuerySnapshot* snapshot = query_future.result();
if (snapshot == nullptr) {
LogMessage("ERROR: failed to fetch query result.");
} else {
Expand Down
2 changes: 1 addition & 1 deletion firestore/testapp/src/desktop/desktop_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ int64_t WinGetCurrentTimeInMicroseconds() {

// Windows file time is expressed in 100s of nanoseconds.
// To convert to microseconds, multiply x10.
return now.QuadPart * 10LL;
return now.QuadPart * 10;
}
#endif
Loading