2016-02-18 11:59:34 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright 2016 Realm Inc.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2015-08-13 09:12:48 -07:00
|
|
|
|
2015-12-01 14:44:09 -08:00
|
|
|
#include "platform.hpp"
|
2016-04-12 14:42:05 -07:00
|
|
|
#include "realm_coordinator.hpp"
|
2015-12-01 14:44:09 -08:00
|
|
|
|
2017-01-31 14:07:29 +01:00
|
|
|
#if REALM_ENABLE_SYNC
|
|
|
|
#include "sync/sync_manager.hpp"
|
|
|
|
#include "sync/sync_user.hpp"
|
|
|
|
#endif
|
|
|
|
|
2016-03-30 09:16:38 -07:00
|
|
|
namespace realm {
|
|
|
|
namespace js {
|
2015-08-13 09:12:48 -07:00
|
|
|
|
2016-04-12 14:42:05 -07:00
|
|
|
static std::string s_default_path = "";
|
|
|
|
|
2016-03-30 09:16:38 -07:00
|
|
|
std::string default_path() {
|
2016-04-12 14:42:05 -07:00
|
|
|
if (s_default_path.size() == 0) {
|
|
|
|
s_default_path = realm::default_realm_file_directory() + "/default.realm";
|
2016-01-12 08:16:13 -08:00
|
|
|
}
|
2016-04-12 14:42:05 -07:00
|
|
|
return s_default_path;
|
2015-08-13 09:12:48 -07:00
|
|
|
}
|
|
|
|
|
2016-03-30 09:16:38 -07:00
|
|
|
void set_default_path(std::string path) {
|
2016-04-12 14:42:05 -07:00
|
|
|
s_default_path = path;
|
|
|
|
}
|
|
|
|
|
2016-04-17 22:49:07 -07:00
|
|
|
void delete_all_realms() {
|
2016-04-12 14:42:05 -07:00
|
|
|
realm::_impl::RealmCoordinator::clear_all_caches();
|
|
|
|
realm::remove_realm_files_from_directory(realm::default_realm_file_directory());
|
2015-08-13 09:12:48 -07:00
|
|
|
}
|
2016-03-29 16:17:57 -07:00
|
|
|
|
2017-01-31 14:07:29 +01:00
|
|
|
void clear_test_state() {
|
|
|
|
delete_all_realms();
|
|
|
|
#if REALM_ENABLE_SYNC
|
|
|
|
for(auto &user : SyncManager::shared().all_logged_in_users()) {
|
|
|
|
user->log_out();
|
|
|
|
}
|
|
|
|
SyncManager::shared().reset_for_testing();
|
|
|
|
SyncManager::shared().configure_file_system(default_realm_file_directory(), SyncManager::MetadataMode::NoEncryption);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-03-30 14:11:57 -07:00
|
|
|
} // js
|
|
|
|
} // realm
|