Compare commits

...
Sign in to create a new pull request.

6 commits

Author SHA1 Message Date
Viktor Govako
3aa5151e62 MyPosition startup refactoring. 2022-04-26 23:35:21 +03:00
Viktor Govako
ef3d94a116 [android][drape] Cleanup my-position-mode startup logic.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
2022-04-26 19:18:12 +03:00
Viktor Govako
3b66174fb3 [android] Ignore possible false-positive location availability.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
2022-04-26 19:18:12 +03:00
Viktor Govako
b53cd405d4 [tests] Relaxed SmallMap benchmark.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
2022-04-26 09:58:23 +03:00
Viktor Govako
eda6c8cd25 [tests] Minor renaming.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
2022-04-24 20:16:32 +03:00
Viktor Govako
8cf09beb8f [drape] Removed assert.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
2022-04-24 20:16:32 +03:00
25 changed files with 247 additions and 276 deletions

View file

@ -37,16 +37,17 @@ class GoogleFusedLocationProvider extends BaseLocationProvider
// Documentation is inconsistent with the code: "returns null if no locations are available".
// https://developers.google.com/android/reference/com/google/android/gms/location/LocationResult#getLastLocation()
//noinspection ConstantConditions
if (location == null)
return;
mListener.onLocationChanged(location);
if (location != null)
mListener.onLocationChanged(location);
}
@Override
public void onLocationAvailability(@NonNull LocationAvailability availability)
{
if (!availability.isLocationAvailable())
mListener.onLocationError(ERROR_GPS_OFF);
if (!availability.isLocationAvailable()) {
LOGGER.w(TAG, "isLocationAvailable returned false");
//mListener.onLocationError(ERROR_GPS_OFF);
}
}
}

View file

@ -106,8 +106,6 @@ enum MultiTouchAction
Framework::Framework()
: m_lastCompass(0.0)
, m_isSurfaceDestroyed(false)
, m_currentMode(location::PendingPosition)
, m_isCurrentModeInitialized(false)
, m_isChoosePositionMode(false)
{
m_work.GetTrafficManager().SetStateListener(bind(&Framework::TrafficStateChanged, this, _1));
@ -234,8 +232,6 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
p.m_surfaceHeight = oglFactory->GetHeight();
}
p.m_visualScale = static_cast<float>(dp::VisualScale(densityDpi));
p.m_hasMyPositionState = m_isCurrentModeInitialized;
p.m_initialMyPositionState = m_currentMode;
p.m_isChoosePositionMode = m_isChoosePositionMode;
p.m_hints.m_isFirstLaunch = firstLaunch;
p.m_hints.m_isLaunchByDeepLink = launchByDeepLink;
@ -253,7 +249,7 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
return true;
}
bool Framework::IsDrapeEngineCreated()
bool Framework::IsDrapeEngineCreated() const
{
return m_work.IsDrapeEngineCreated();
}
@ -642,23 +638,12 @@ void Framework::SetMyPositionModeListener(location::TMyPositionModeChanged const
m_myPositionModeSignal = fn;
}
location::EMyPositionMode Framework::GetMyPositionMode()
location::EMyPositionMode Framework::GetMyPositionMode() const
{
if (!m_isCurrentModeInitialized)
{
if (!settings::Get(settings::kLocationStateMode, m_currentMode))
m_currentMode = location::NotFollowNoPosition;
// No need in assertion here, return location::PendingPosition if no engine created.
//ASSERT(IsDrapeEngineCreated(), ());
m_isCurrentModeInitialized = true;
}
return m_currentMode;
}
void Framework::OnMyPositionModeChanged(location::EMyPositionMode mode)
{
m_currentMode = mode;
m_isCurrentModeInitialized = true;
return m_work.GetMyPositionMode();
}
void Framework::SwitchMyPositionNextMode()
@ -1673,12 +1658,6 @@ Java_com_mapswithme_maps_Framework_nativeIsRouteFinished(JNIEnv * env, jclass)
return frm()->GetRoutingManager().IsRouteFinished();
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_nativeRunFirstLaunchAnimation(JNIEnv * env, jclass)
{
frm()->RunFirstLaunchAnimation();
}
JNIEXPORT jint JNICALL
Java_com_mapswithme_maps_Framework_nativeOpenRoutePointsTransaction(JNIEnv * env, jclass)
{

View file

@ -70,8 +70,6 @@ namespace android
void MyPositionModeChanged(location::EMyPositionMode mode, bool routingActive);
location::TMyPositionModeChanged m_myPositionModeSignal;
location::EMyPositionMode m_currentMode;
bool m_isCurrentModeInitialized;
TrafficManager::TrafficStateChangedFn m_onTrafficStateChangedFn;
TransitReadManager::TransitStateChangedFn m_onTransitStateChangedFn;
@ -93,7 +91,7 @@ namespace android
bool CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi, bool firstLaunch,
bool launchByDeepLink, uint32_t appVersionCode);
bool IsDrapeEngineCreated();
bool IsDrapeEngineCreated() const;
bool DestroySurfaceOnDetach();
void DetachSurface(bool destroySurface);
bool AttachSurface(JNIEnv * env, jobject jSurface);
@ -160,8 +158,7 @@ namespace android
// std::string GetOutdatedCountriesString();
void SetMyPositionModeListener(location::TMyPositionModeChanged const & fn);
location::EMyPositionMode GetMyPositionMode();
void OnMyPositionModeChanged(location::EMyPositionMode mode);
location::EMyPositionMode GetMyPositionMode() const;
void SwitchMyPositionNextMode();
void SetTrafficStateListener(TrafficManager::TrafficStateChangedFn const & fn);

View file

@ -10,8 +10,6 @@ extern "C"
static void LocationStateModeChanged(location::EMyPositionMode mode,
std::shared_ptr<jobject> const & listener)
{
g_framework->OnMyPositionModeChanged(mode);
JNIEnv * env = jni::GetEnv();
env->CallVoidMethod(*listener, jni::GetMethodID(env, *listener.get(),
"onMyPositionModeChanged", "(I)V"), static_cast<jint>(mode));

View file

@ -361,8 +361,6 @@ public class Framework
// Navigation.
public static native boolean nativeIsRouteFinished();
public static native void nativeRunFirstLaunchAnimation();
public static native int nativeOpenRoutePointsTransaction();
public static native void nativeApplyRoutePointsTransaction(int transactionId);
public static native void nativeCancelRoutePointsTransaction(int transactionId);

View file

@ -124,7 +124,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
NoConnectionListener,
MapWidgetOffsetsProvider
{
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
private final Logger mLogger = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
private static final String TAG = MwmActivity.class.getSimpleName();
public static final String EXTRA_TASK = "map_task";

View file

@ -154,12 +154,14 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
};
@SuppressWarnings("FieldCanBeLocal")
private final LocationState.LocationPendingTimeoutListener mLocationPendingTimeoutListener =
() -> {
stop();
if (PermissionsUtils.isLocationGranted(mContext) && LocationUtils.areLocationServicesTurnedOn(mContext))
notifyLocationNotFound();
};
private final LocationState.LocationPendingTimeoutListener mLocationPendingTimeoutListener = () -> {
if (mActive)
{
stop();
if (PermissionsUtils.isLocationGranted(mContext) && LocationUtils.areLocationServicesTurnedOn(mContext))
notifyLocationNotFound();
}
};
@Override
public void initialize(@NotNull Context context)
@ -246,7 +248,7 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
mReceiverRegistered = false;
}
start();
initialStart();
}
else
{
@ -319,11 +321,15 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
public void onLocationError(int errCode)
{
mLogger.d(TAG, "onLocationError(): " + errCode);
if (errCode == ERROR_NOT_SUPPORTED && !(mLocationProvider instanceof AndroidNativeProvider))
if (errCode == ERROR_NOT_SUPPORTED &&
LocationUtils.areLocationServicesTurnedOn(mContext) &&
!(mLocationProvider instanceof AndroidNativeProvider))
{
// Try to downgrade to native provider first before notifying the user.
// If location service is enabled, try to downgrade to the native provider first
// and restart the service before notifying the user.
mLogger.d(TAG, "Downgrading to use native provider");
mLocationProvider = new AndroidNativeProvider(mContext, this);
restart();
return;
}
@ -436,11 +442,16 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
*/
public void restart()
{
mLogger.i(TAG, "restart()");
stop();
start();
}
private void initialStart()
{
if (LocationState.nativeGetMode() != LocationState.NOT_FOLLOW_NO_POSITION)
start();
}
/**
* Adds the {@link #mCoreLocationListener} to listen location updates and notify UI.
* Notifies about {@link #ERROR_DENIED} if there are no enabled location providers.
@ -451,7 +462,7 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
{
if (mActive)
{
mLogger.i(TAG, "Provider '" + mLocationProvider + "' is already started");
mLogger.w(TAG, "Provider '" + mLocationProvider + "' is already started");
return;
}
@ -488,7 +499,7 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
mLogger.i(TAG, "stop()");
if (!mActive)
{
mLogger.i(TAG, "Provider '" + mLocationProvider + "' is already stopped");
mLogger.w(TAG, "Provider '" + mLocationProvider + "' is already stopped");
return;
}
@ -549,7 +560,7 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
}
else
{
restart();
initialStart();
}
}
@ -593,23 +604,11 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
mInFirstRun = false;
if (getMyPositionMode() != LocationState.NOT_FOLLOW_NO_POSITION)
throw new AssertionError("My position mode must be equal NOT_FOLLOW_NO_POSITION");
// If there is a location we need just to pass it to the listeners, so that
// my position state machine will be switched to the FOLLOW state.
// Otherwise, restart location service to show alert dialog if any location error.
if (mSavedLocation != null)
{
notifyLocationUpdated();
mLogger.d(TAG, "Current location is available, so play the nice zoom animation");
Framework.nativeRunFirstLaunchAnimation();
return;
}
// If the location hasn't been obtained yet we need to switch to the next mode and wait for locations.
// Otherwise, try to restart location updates polling.
if (mActive)
switchToNextMode();
else
restart();
}

View file

@ -5,6 +5,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Build;
import android.provider.Settings;
import android.view.Surface;
@ -99,17 +100,20 @@ public class LocationUtils
return newLocation.getAccuracy() < lastAccuracy;
}
@SuppressLint("InlinedApi")
@SuppressWarnings("deprecation")
public static boolean areLocationServicesTurnedOn(@NonNull Context context)
{
final ContentResolver resolver = context.getContentResolver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
{
final LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
return lm.isLocationEnabled();
}
try
{
return Settings.Secure.getInt(resolver, Settings.Secure.LOCATION_MODE)
return Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE)
!= Settings.Secure.LOCATION_MODE_OFF;
} catch (Settings.SettingNotFoundException e)
}
catch (Settings.SettingNotFoundException e)
{
e.printStackTrace();
return false;

View file

@ -265,7 +265,7 @@ UNIT_TEST(SmallMap_Benchmark3)
TEST_EQUAL(sum1, sum2, ());
TEST_EQUAL(sum1, sum3, ());
TEST_LESS(t2, t1, ());
TEST_LESS(t3, t2, ());
TEST(BenchmarkTimeLessOrNear(t3, t2, 0.05), (t3, t2));
LOG(LINFO, ("unordered_map time =", t1, "SmallMap time =", t2, "SmallMapBase time =", t3));
}
#endif

View file

@ -223,7 +223,8 @@ void OverlayTree::Add(ref_ptr<OverlayHandle> handle)
void OverlayTree::InsertHandle(ref_ptr<OverlayHandle> handle, int currentRank,
ref_ptr<OverlayHandle> const & parentOverlay)
{
ASSERT(handle->GetOverlayID().IsValid(), ());
/// @todo Fires when updating country (delete-add) ?!
//ASSERT(handle->GetOverlayID().IsValid(), ());
ASSERT(IsNeedUpdate(), ());
#ifdef DEBUG_OVERLAYS_OUTPUT

View file

@ -1,7 +1,7 @@
#include "drape_frontend/drape_engine.hpp"
#include "drape_frontend/message_subclasses.hpp"
#include "drape_frontend/gui/drape_gui.hpp"
#include "drape_frontend/message_subclasses.hpp"
#include "drape_frontend/my_position_controller.hpp"
#include "drape_frontend/visual_params.hpp"
@ -13,10 +13,28 @@
#include <unordered_map>
using namespace std::placeholders;
namespace df
{
using namespace std::placeholders;
namespace
{
std::string const kLocationStateMode = "LastLocationStateMode";
std::string const kLastEnterBackground = "LastEnterBackground";
std::string const kLastViewport = "ScreenClipRect";
}
void SaveViewportSetting(m2::AnyRectD const & r)
{
settings::Set(kLastViewport, r);
}
bool LoadViewportSetting(m2::AnyRectD & r)
{
return settings::Get(kLastViewport, r) && GetWorldRect().IsRectInside(r.GetGlobalRect());
}
DrapeEngine::DrapeEngine(Params && params)
: m_myPositionModeChanged(std::move(params.m_myPositionModeChanged))
, m_viewport(std::move(params.m_viewport))
@ -34,24 +52,20 @@ DrapeEngine::DrapeEngine(Params && params)
m_threadCommutator = make_unique_dp<ThreadsCommutator>();
m_requestedTiles = make_unique_dp<RequestedTiles>();
location::EMyPositionMode mode = params.m_initialMyPositionMode.first;
if (!params.m_initialMyPositionMode.second && !settings::Get(settings::kLocationStateMode, mode))
{
mode = location::PendingPosition;
}
else if (mode == location::FollowAndRotate)
using namespace location;
EMyPositionMode mode = PendingPosition;
if (settings::Get(kLocationStateMode, mode) && mode == FollowAndRotate)
{
// If the screen rect setting in follow and rotate mode is missing or invalid, it could cause
// invalid animations, so the follow and rotate mode should be discarded.
m2::AnyRectD rect;
if (!(settings::Get("ScreenClipRect", rect) && df::GetWorldRect().IsRectInside(rect.GetGlobalRect())))
mode = location::Follow;
m2::AnyRectD dummy;
if (!LoadViewportSetting(dummy))
mode = Follow;
}
double timeInBackground = 0.0;
double lastEnterBackground = 0.0;
if (settings::Get("LastEnterBackground", lastEnterBackground))
timeInBackground = base::Timer::LocalTime() - lastEnterBackground;
if (settings::Get(kLastEnterBackground, timeInBackground))
timeInBackground = base::Timer::LocalTime() - timeInBackground;
std::vector<PostprocessRenderer::Effect> effects;
@ -448,11 +462,16 @@ void DrapeEngine::ModelViewChanged(ScreenBase const & screen)
void DrapeEngine::MyPositionModeChanged(location::EMyPositionMode mode, bool routingActive)
{
settings::Set(settings::kLocationStateMode, mode);
if (m_myPositionModeChanged != nullptr)
settings::Set(kLocationStateMode, mode);
if (m_myPositionModeChanged)
m_myPositionModeChanged(mode, routingActive);
}
location::EMyPositionMode DrapeEngine::GetMyPositionMode() const
{
return m_frontend->GetMyPositionMode();
}
void DrapeEngine::TapEvent(TapInfo const & tapInfo)
{
if (m_tapEventInfoHandler != nullptr)
@ -724,8 +743,9 @@ void DrapeEngine::SetKineticScrollEnabled(bool enabled)
MessagePriority::Normal);
}
void DrapeEngine::OnEnterForeground(double backgroundTime)
void DrapeEngine::OnEnterForeground()
{
double const backgroundTime = base::Timer::LocalTime() - m_startBackgroundTime;
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
make_unique_dp<OnEnterForegroundMessage>(backgroundTime),
MessagePriority::High);
@ -733,6 +753,9 @@ void DrapeEngine::OnEnterForeground(double backgroundTime)
void DrapeEngine::OnEnterBackground()
{
m_startBackgroundTime = base::Timer::LocalTime();
settings::Set(kLastEnterBackground, m_startBackgroundTime);
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
make_unique_dp<OnEnterBackgroundMessage>(),
MessagePriority::High);
@ -873,13 +896,6 @@ void DrapeEngine::SetPosteffectEnabled(PostprocessRenderer::Effect effect, bool
MessagePriority::Normal);
}
void DrapeEngine::RunFirstLaunchAnimation()
{
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
make_unique_dp<RunFirstLaunchAnimationMessage>(),
MessagePriority::Normal);
}
void DrapeEngine::ShowDebugInfo(bool shown)
{
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,

View file

@ -46,6 +46,9 @@ namespace df
class UserMarksProvider;
class MapDataProvider;
void SaveViewportSetting(m2::AnyRectD const & r);
bool LoadViewportSetting(m2::AnyRectD & r);
class DrapeEngine
{
public:
@ -59,7 +62,6 @@ public:
double vs,
double fontsScaleFactor,
gui::TWidgetsInitInfo && info,
std::pair<location::EMyPositionMode, bool> const & initialMyPositionMode,
location::TMyPositionModeChanged && myPositionModeChanged,
bool allow3dBuildings,
bool trafficEnabled,
@ -80,7 +82,6 @@ public:
, m_vs(vs)
, m_fontsScaleFactor(fontsScaleFactor)
, m_info(std::move(info))
, m_initialMyPositionMode(initialMyPositionMode)
, m_myPositionModeChanged(std::move(myPositionModeChanged))
, m_allow3dBuildings(allow3dBuildings)
, m_trafficEnabled(trafficEnabled)
@ -207,7 +208,7 @@ public:
void SetKineticScrollEnabled(bool enabled);
void OnEnterForeground(double backgroundTime);
void OnEnterForeground();
void OnEnterBackground();
using TRequestSymbolsSizeCallback = std::function<void(std::map<std::string, m2::PointF> &&)>;
@ -243,13 +244,13 @@ public:
void SetPosteffectEnabled(PostprocessRenderer::Effect effect, bool enabled);
void EnableDebugRectRendering(bool enabled);
void RunFirstLaunchAnimation();
void ShowDebugInfo(bool shown);
void UpdateVisualScale(double vs, bool needStopRendering);
void UpdateMyPositionRoutingOffset(bool useDefault, int offsetY);
location::EMyPositionMode GetMyPositionMode() const;
private:
void AddUserEvent(drape_ptr<UserEvent> && e);
void PostUserEvent(drape_ptr<UserEvent> && e);
@ -291,6 +292,8 @@ private:
std::atomic<dp::DrapeID> m_drapeIdGenerator = 0;
double m_startBackgroundTime = 0;
friend class DrapeApi;
};
} // namespace df

View file

@ -150,6 +150,8 @@ public:
drape_ptr<ScenarioManager> const & GetScenarioManager() const;
location::EMyPositionMode GetMyPositionMode() const { return m_myPositionController->GetCurrentMode(); }
protected:
void AcceptMessage(ref_ptr<Message> message) override;
std::unique_ptr<threads::IRoutine> CreateRoutine() override;

View file

@ -118,13 +118,10 @@ bool IsModeChangeViewport(location::EMyPositionMode mode)
MyPositionController::MyPositionController(Params && params, ref_ptr<DrapeNotifier> notifier)
: m_notifier(notifier)
, m_mode(params.m_isRoutingActive || df::IsModeChangeViewport(params.m_initMode)
? location::PendingPosition
: location::NotFollowNoPosition)
, m_desiredInitMode(params.m_initMode)
, m_modeChangeCallback(std::move(params.m_myPositionModeCallback))
, m_hints(params.m_hints)
, m_isInRouting(params.m_isRoutingActive)
, m_screenshotMode(params.m_hints.m_screenshotMode)
, m_followZoomLevel(13) // is taken from FrontendRenderer::CheckAndRunFirstLaunchAnimation()
, m_needBlockAnimation(false)
, m_wasRotationInScaling(false)
, m_errorRadius(0.0)
@ -153,22 +150,38 @@ MyPositionController::MyPositionController(Params && params, ref_ptr<DrapeNotifi
, m_blockAutoZoomNotifyId(DrapeNotifier::kInvalidId)
, m_updateLocationNotifyId(DrapeNotifier::kInvalidId)
{
if (m_hints.m_isFirstLaunch)
using namespace location;
if (params.m_hints.m_isFirstLaunch)
{
m_mode = location::NotFollowNoPosition;
m_desiredInitMode = location::Follow;
m_mode = PendingPosition;
m_desiredInitMode = Follow;
}
else if (m_hints.m_isLaunchByDeepLink)
else if (params.m_hints.m_isLaunchByDeepLink)
{
m_desiredInitMode = location::NotFollow;
m_mode = NotFollowNoPosition;
m_desiredInitMode = NotFollow;
}
else if (params.m_timeInBackground >= kMaxTimeInBackgroundSec)
{
m_mode = location::PendingPosition;
m_desiredInitMode = location::Follow;
m_mode = PendingPosition;
m_desiredInitMode = Follow;
}
else
{
// Restore PendingPosition mode (and start location service on platform side accordingly)
// if we have routing mode or FollowXXX desired mode (usually loaded from settings).
m_desiredInitMode = params.m_initMode;
m_mode = (params.m_isRoutingActive || df::IsModeChangeViewport(m_desiredInitMode)) ?
PendingPosition : NotFollowNoPosition;
// If we restored state, do not make auto-zoom until user will trigger the location.
m_followZoomLevel = kDoNotChangeZoom;
}
if (m_modeChangeCallback != nullptr)
m_pendingStarted = (m_mode == PendingPosition);
if (m_modeChangeCallback)
m_modeChangeCallback(m_mode, m_isInRouting);
}
@ -324,6 +337,7 @@ void MyPositionController::ResetRenderShape()
void MyPositionController::NextMode(ScreenBase const & screen)
{
m_followZoomLevel = kMaxScaleZoomLevel;
// Skip switching to next mode while we are waiting for position.
if (IsWaitingForLocation())
@ -332,7 +346,6 @@ void MyPositionController::NextMode(ScreenBase const & screen)
return;
}
// Start looking for location.
if (m_mode == location::NotFollowNoPosition)
{
@ -435,31 +448,35 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool
m_positionIsObsolete = false;
}
if (!m_isPositionAssigned)
if (m_followZoomLevel == kDoNotChangeZoom)
{
// If the position was never assigned, the new mode will be desired one except the case when
// we touch the map during the pending of position. In this case the current mode must be
// NotFollowNoPosition, new mode will be NotFollow to prevent spontaneous map snapping.
// If the position was never assigned, the new mode will be the desired one except next cases:
location::EMyPositionMode newMode = m_desiredInitMode;
if (m_mode == location::NotFollowNoPosition)
{
// We touch the map during the PendingPosition mode and current mode was converted into NotFollowNoPosition.
// New mode will be NotFollow to prevent spontaneous map snapping.
ResetRoutingNotFollowTimer();
newMode = location::NotFollow;
}
else if (m_mode == location::PendingPosition && newMode < location::Follow)
{
// This is the first user location request (button touch) after controller's initialization
// with some previous not Follow state. New mode will be Follow to move on current position.
newMode = location::Follow;
}
ChangeMode(newMode);
if (!m_hints.m_isFirstLaunch || !AnimationSystem::Instance().AnimationExists(Animation::Object::MapPlane))
if (m_mode == location::Follow)
{
if (m_mode == location::Follow)
{
ChangeModelView(m_position, kDoNotChangeZoom);
}
else if (m_mode == location::FollowAndRotate)
{
ChangeModelView(m_position, m_drawDirection,
m_isInRouting ? GetRoutingRotationPixelCenter() : m_visiblePixelRect.Center(),
kDoNotChangeZoom);
}
ChangeModelView(m_position, kDoNotChangeZoom);
}
else if (m_mode == location::FollowAndRotate)
{
ChangeModelView(m_position, m_drawDirection,
m_isInRouting ? GetRoutingRotationPixelCenter() : m_visiblePixelRect.Center(),
kDoNotChangeZoom);
}
}
else if (m_mode == location::PendingPosition)
@ -472,22 +489,15 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool
else
{
ChangeMode(location::Follow);
if (m_hints.m_isFirstLaunch)
if (GetZoomLevel(screen, m_position, m_errorRadius) <= m_followZoomLevel)
{
if (!AnimationSystem::Instance().AnimationExists(Animation::Object::MapPlane))
ChangeModelView(m_position, kDoNotChangeZoom);
m2::PointD const size(m_errorRadius, m_errorRadius);
ChangeModelView(m2::RectD(m_position - size, m_position + size));
}
else
{
if (GetZoomLevel(screen, m_position, m_errorRadius) <= kMaxScaleZoomLevel)
{
m2::PointD const size(m_errorRadius, m_errorRadius);
ChangeModelView(m2::RectD(m_position - size, m_position + size));
}
else
{
ChangeModelView(m_position, kMaxScaleZoomLevel);
}
ChangeModelView(m_position, m_followZoomLevel);
}
}
}
@ -598,7 +608,7 @@ void MyPositionController::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<
m_shape->SetAccuracy(static_cast<float>(m_errorRadius));
m_shape->SetRoutingMode(IsInRouting());
if (!m_hints.m_screenshotMode)
if (!m_screenshotMode)
{
m_shape->RenderAccuracy(context, mng, screen, zoomLevel, frameValues);
m_shape->RenderMyPosition(context, mng, screen, zoomLevel, frameValues);
@ -645,7 +655,7 @@ void MyPositionController::ChangeMode(location::EMyPositionMode newMode)
}
m_mode = newMode;
if (m_modeChangeCallback != nullptr)
if (m_modeChangeCallback)
m_modeChangeCallback(m_mode, m_isInRouting);
}
@ -653,7 +663,7 @@ bool MyPositionController::IsWaitingForLocation() const
{
if (m_mode == location::NotFollowNoPosition)
return false;
if (!m_isPositionAssigned)
return true;
@ -742,7 +752,7 @@ void MyPositionController::UpdateViewport(int zoomLevel)
{
if (IsWaitingForLocation())
return;
if (m_mode == location::Follow)
{
ChangeModelView(m_position, zoomLevel);
@ -759,7 +769,7 @@ m2::PointD MyPositionController::GetRotationPixelCenter() const
{
if (m_mode == location::Follow)
return m_visiblePixelRect.Center();
if (m_mode == location::FollowAndRotate)
return m_isInRouting ? GetRoutingRotationPixelCenter() : m_visiblePixelRect.Center();

View file

@ -114,6 +114,7 @@ public:
void StopLocationFollow();
void NextMode(ScreenBase const & screen);
void LoseLocation();
location::EMyPositionMode GetCurrentMode() const { return m_mode; }
void OnEnterForeground(double backgroundTime);
void OnEnterBackground();
@ -166,10 +167,12 @@ private:
location::EMyPositionMode m_mode;
location::EMyPositionMode m_desiredInitMode;
location::TMyPositionModeChanged m_modeChangeCallback;
Hints m_hints;
bool m_isInRouting = false;
bool m_isArrowGluedInRouting = false;
bool m_screenshotMode = false;
int m_followZoomLevel;
bool m_needBlockAnimation;
bool m_wasRotationInScaling;
@ -191,7 +194,7 @@ private:
base::Timer m_lastGPSBearingTimer;
base::Timer m_pendingTimer;
bool m_pendingStarted = true;
bool m_pendingStarted;
base::Timer m_routingNotFollowTimer;
bool m_blockRoutingNotFollowTimer = false;
base::Timer m_blockAutoZoomTimer;

View file

@ -14,7 +14,6 @@ typedef void (^SearchInDownloaderCompletions)(NSArray<MWMMapSearchResult *> *res
NS_SWIFT_NAME(FrameworkHelper)
@interface MWMFrameworkHelper : NSObject
+ (void)processFirstLaunch:(BOOL)hasLocation;
+ (void)setVisibleViewport:(CGRect)rect scaleFactor:(CGFloat)scale;
+ (void)setTheme:(MWMTheme)theme;
+ (MWMDayTime)daytimeAtLocation:(nullable CLLocation *)location;

View file

@ -10,14 +10,6 @@
@implementation MWMFrameworkHelper
+ (void)processFirstLaunch:(BOOL)hasLocation {
auto &f = GetFramework();
if (!hasLocation)
f.SwitchMyPositionNextMode();
else
f.RunFirstLaunchAnimation();
}
+ (void)setVisibleViewport:(CGRect)rect scaleFactor:(CGFloat)scale {
CGFloat const x0 = rect.origin.x * scale;
CGFloat const y0 = rect.origin.y * scale;

View file

@ -324,9 +324,6 @@ NSString *const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing";
if ([FirstSession isFirstSession])
{
[MWMLocationManager start];
dispatch_async(dispatch_get_main_queue(), ^{
[MWMFrameworkHelper processFirstLaunch:[MWMLocationManager isStarted]];
});
}
else
{

View file

@ -3,7 +3,6 @@
#include "platform/localization.hpp"
#include "platform/location.hpp"
#include "platform/measurement_utils.hpp"
#include "platform/settings.hpp"
#include "geometry/mercator.hpp"
@ -18,15 +17,6 @@ static inline NSString * formattedDistance(double const & meters) {
return @(measurement_utils::FormatDistanceWithLocalization(meters, localizedUnits.m_high, localizedUnits.m_low).c_str());
}
static inline BOOL isMyPositionPendingOrNoPosition()
{
location::EMyPositionMode mode;
if (!settings::Get(settings::kLocationStateMode, mode))
return true;
return mode == location::EMyPositionMode::PendingPosition ||
mode == location::EMyPositionMode::NotFollowNoPosition;
}
static inline ms::LatLon ToLatLon(m2::PointD const & p) { return mercator::ToLatLon(p); }
static inline m2::PointD ToMercator(CLLocationCoordinate2D const & l)
@ -46,4 +36,4 @@ static inline MWMMyPositionMode mwmMyPositionMode(location::EMyPositionMode mode
case location::EMyPositionMode::FollowAndRotate: return MWMMyPositionModeFollowAndRotate;
}
}
} // namespace MWMLocationHelpers
} // namespace location_helpers

View file

@ -279,20 +279,23 @@ char const *kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeIm
auto const doStart = ^{
auto &rm = GetFramework().GetRoutingManager();
auto const routePoints = rm.GetRoutePoints();
if (routePoints.size() >= 2) {
if (routePoints.size() >= 2)
{
auto p1 = [[MWMRoutePoint alloc] initWithRouteMarkData:routePoints.front()];
auto p2 = [[MWMRoutePoint alloc] initWithRouteMarkData:routePoints.back()];
if (p1.isMyPosition && [MWMLocationManager lastLocation]) {
CLLocation *lastLocation = [MWMLocationManager lastLocation];
if (p1.isMyPosition && lastLocation)
{
rm.FollowRoute();
[[MWMMapViewControlsManager manager] onRouteStart];
[MWMThemeManager setAutoUpdates:YES];
} else {
MWMAlertViewController *alertController = [MWMAlertViewController activeAlertController];
CLLocation *lastLocation = [MWMLocationManager lastLocation];
BOOL const needToRebuild =
lastLocation && !location_helpers::isMyPositionPendingOrNoPosition() && !p2.isMyPosition;
[alertController
}
else
{
BOOL const needToRebuild = lastLocation && [MWMLocationManager isStarted] && !p2.isMyPosition;
[[MWMAlertViewController activeAlertController]
presentPoint2PointAlertWithOkBlock:^{
[self buildFromPoint:[[MWMRoutePoint alloc] initWithLastLocationAndType:MWMRoutePointTypeStart
intermediateIndex:0]

View file

@ -104,7 +104,6 @@
using namespace location;
using namespace routing;
using namespace storage;
using namespace std::chrono;
using namespace std::placeholders;
using namespace std;
@ -237,6 +236,11 @@ void Framework::SetMyPositionPendingTimeoutListener(df::DrapeEngine::UserPositio
m_myPositionPendingTimeoutListener = move(fn);
}
EMyPositionMode Framework::GetMyPositionMode() const
{
return m_drapeEngine ? m_drapeEngine->GetMyPositionMode() : PendingPosition;
}
TrafficManager & Framework::GetTrafficManager()
{
return m_trafficManager;
@ -896,18 +900,17 @@ void Framework::SaveViewport()
rect = modelView.GlobalRect();
}
else
{
rect = m_currentModelView.GlobalRect();
}
settings::Set("ScreenClipRect", rect);
df::SaveViewportSetting(rect);
}
void Framework::LoadViewport()
{
m2::AnyRectD rect;
if (settings::Get("ScreenClipRect", rect) && df::GetWorldRect().IsRectInside(rect.GetGlobalRect()))
if (df::LoadViewportSetting(rect))
{
if (m_drapeEngine != nullptr)
if (m_drapeEngine)
m_drapeEngine->SetModelViewAnyRect(rect, false /* isAnim */, false /* useVisibleViewport */);
}
else
@ -1071,12 +1074,6 @@ int Framework::GetDrawScale() const
return 0;
}
void Framework::RunFirstLaunchAnimation()
{
if (m_drapeEngine != nullptr)
m_drapeEngine->RunFirstLaunchAnimation();
}
bool Framework::IsCountryLoaded(m2::PointD const & pt) const
{
// TODO (@gorshenin, @govako): the method's name is quite
@ -1141,10 +1138,7 @@ void Framework::MemoryWarning()
void Framework::EnterBackground()
{
m_startBackgroundTime = base::Timer::LocalTime();
settings::Set("LastEnterBackground", m_startBackgroundTime);
if (m_drapeEngine != nullptr)
if (m_drapeEngine)
m_drapeEngine->OnEnterBackground();
SaveViewport();
@ -1161,12 +1155,8 @@ void Framework::EnterBackground()
void Framework::EnterForeground()
{
m_startForegroundTime = base::Timer::LocalTime();
if (m_drapeEngine != nullptr && m_startBackgroundTime != 0.0)
{
auto const secondsInBackground = m_startForegroundTime - m_startBackgroundTime;
m_drapeEngine->OnEnterForeground(secondsInBackground);
}
if (m_drapeEngine)
m_drapeEngine->OnEnterForeground();
m_trafficManager.OnEnterForeground();
}
@ -1507,7 +1497,6 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFac
df::MapDataProvider(move(idReadFn), move(featureReadFn),
move(isCountryLoadedByNameFn), move(updateCurrentCountryFn)),
params.m_hints, params.m_visualScale, fontsScaleFactor, move(params.m_widgetsInitInfo),
make_pair(params.m_initialMyPositionState, params.m_hasMyPositionState),
move(myPositionModeChangedFn), allow3dBuildings,
trafficEnabled, isolinesEnabled,
params.m_isChoosePositionMode, params.m_isChoosePositionMode, GetSelectedFeatureTriangles(),
@ -1522,19 +1511,22 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFac
});
m_drapeEngine->SetTapEventInfoListener([this](df::TapInfo const & tapInfo)
{
GetPlatform().RunTask(Platform::Thread::Gui, [this, tapInfo]() {
GetPlatform().RunTask(Platform::Thread::Gui, [this, tapInfo]()
{
OnTapEvent(place_page::BuildInfo(tapInfo));
});
});
m_drapeEngine->SetUserPositionListener([this](m2::PointD const & position, bool hasPosition)
{
GetPlatform().RunTask(Platform::Thread::Gui, [this, position, hasPosition](){
GetPlatform().RunTask(Platform::Thread::Gui, [this, position, hasPosition]()
{
OnUserPositionChanged(position, hasPosition);
});
});
m_drapeEngine->SetUserPositionPendingTimeoutListener([this]()
{
GetPlatform().RunTask(Platform::Thread::Gui, [this](){
GetPlatform().RunTask(Platform::Thread::Gui, [this]()
{
if (m_myPositionPendingTimeoutListener)
m_myPositionPendingTimeoutListener();
});
@ -3237,11 +3229,6 @@ bool Framework::HaveTransit(m2::PointD const & pt) const
return handle.GetValue()->m_cont.IsExist(TRANSIT_FILE_TAG);
}
double Framework::GetLastBackgroundTime() const
{
return m_startBackgroundTime;
}
void Framework::OnPowerFacilityChanged(power_management::Facility const facility, bool enabled)
{
if (facility == power_management::Facility::PerspectiveView ||

View file

@ -177,10 +177,6 @@ protected:
drape_ptr<df::DrapeEngine> m_drapeEngine;
// Time in seconds.
double m_startForegroundTime = 0.0;
double m_startBackgroundTime = 0.0;
StorageDownloadingPolicy m_storageDownloadingPolicy;
storage::Storage m_storage;
bool m_enabledDiffs;
@ -400,6 +396,8 @@ public:
void SetMyPositionModeListener(location::TMyPositionModeChanged && fn);
void SetMyPositionPendingTimeoutListener(df::DrapeEngine::UserPositionPendingTimeoutHandler && fn);
location::EMyPositionMode GetMyPositionMode() const;
private:
void OnUserPositionChanged(m2::PointD const & position, bool hasPosition);
@ -412,9 +410,6 @@ public:
int m_surfaceHeight = 0;
gui::TWidgetsInitInfo m_widgetsInitInfo;
bool m_hasMyPositionState = false;
location::EMyPositionMode m_initialMyPositionState = location::PendingPosition;
bool m_isChoosePositionMode = false;
df::Hints m_hints;
};
@ -565,8 +560,6 @@ public:
int GetDrawScale() const;
void RunFirstLaunchAnimation();
/// Set correct viewport, parse API, show balloon.
bool ShowMapForURL(std::string const & url);
url_scheme::ParsedMapApi::ParsingResult ParseAndSetApiURL(std::string const & url);
@ -741,7 +734,6 @@ private:
public:
// TipsApi::Delegate override.
bool HaveTransit(m2::PointD const & pt) const;
double GetLastBackgroundTime() const;
power_management::PowerManager & GetPowerManager() { return m_powerManager; }

View file

@ -16,11 +16,10 @@
#include <iostream>
#include <sstream>
using namespace std;
namespace settings
{
char const * kLocationStateMode = "LastLocationStateMode";
using namespace std;
char const * kMeasurementUnits = "Units";
StringStorage::StringStorage() : StringStorageBase(GetPlatform().SettingsPathForFile(SETTINGS_FILE_NAME)) {}
@ -367,6 +366,7 @@ bool IsFirstLaunchForDate(int date)
}
} // namespace settings
/*
namespace marketing
{
Settings::Settings() : platform::StringStorageBase(GetPlatform().SettingsPathForFile(MARKETING_SETTINGS_FILE_NAME)) {}
@ -378,3 +378,4 @@ Settings & Settings::Instance()
return instance;
}
} // namespace marketing
*/

View file

@ -8,8 +8,6 @@
namespace settings
{
/// Current location state mode. @See location::EMyPositionMode.
extern char const * kLocationStateMode;
/// Metric or Feet.
extern char const * kMeasurementUnits;
@ -57,8 +55,9 @@ inline void Clear() { StringStorage::Instance().Clear(); }
/// Use this function for running some stuff once according to date.
/// @param[in] date Current date in format yymmdd.
bool IsFirstLaunchForDate(int date);
}
} // namespace settings
/*
namespace marketing
{
class Settings : public platform::StringStorageBase
@ -82,3 +81,4 @@ private:
Settings();
};
} // namespace marketing
*/

View file

@ -1,8 +1,7 @@
#include "routing/routing_tests/index_graph_tools.hpp"
#include "testing/testing.hpp"
#include "routing/opening_hours_serdes.hpp"
#include "routing/routing_tests/index_graph_tools.hpp"
#include "coding/bit_streams.hpp"
#include "coding/reader.hpp"
@ -15,16 +14,16 @@
#include <string>
#include <vector>
namespace opening_hours_serdes_tests
{
using namespace routing;
using namespace routing_test;
using Buffer = std::vector<uint8_t>;
namespace
struct OHSerDesTestFixture
{
struct BitReaderWriter
{
BitReaderWriter()
OHSerDesTestFixture()
: m_memWriter(m_buffer)
, m_bitWriter(std::make_unique<BitWriter<MemWriter<Buffer>>>(m_memWriter))
{
@ -152,7 +151,7 @@ void TestMonth(osmoh::RuleSequence const & rule, Month startMonth, Month endMont
0 /* endDay */);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_EnableTests_1)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_EnableTests_1)
{
TEST(!IsEnabled(OpeningHoursSerDes::Header::Bits::Year), ());
Enable(OpeningHoursSerDes::Header::Bits::Year);
@ -167,7 +166,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_EnableTests_1)
TEST(IsEnabled(OpeningHoursSerDes::Header::Bits::Minutes), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_EnableTests_2)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_EnableTests_2)
{
Enable(OpeningHoursSerDes::Header::Bits::Year);
Enable(OpeningHoursSerDes::Header::Bits::WeekDay);
@ -185,7 +184,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_EnableTests_2)
// Test on serialization ranges where start is later than end.
// It is wrong but still possible data.
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_CannotSerialize)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_CannotSerialize)
{
Enable(OpeningHoursSerDes::Header::Bits::Year);
Enable(OpeningHoursSerDes::Header::Bits::Month);
@ -193,7 +192,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_CannotSerialize)
TEST(!Serialize("2020 May 20 - 2018 Nov 30"), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_YearOnly)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_YearOnly)
{
Enable(OpeningHoursSerDes::Header::Bits::Year);
@ -208,7 +207,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_YearOnly)
TestYear(rule, 2019, 2090);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_YearAndMonthOnly)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_YearAndMonthOnly)
{
Enable(OpeningHoursSerDes::Header::Bits::Year);
Enable(OpeningHoursSerDes::Header::Bits::Month);
@ -225,7 +224,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_YearAndMonthOnly)
TestMonth(rule, 2019, Month::Apr, 10, 2051, Month::May, 19);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_1)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Weekday_1)
{
Enable(OpeningHoursSerDes::Header::Bits::WeekDay);
@ -240,7 +239,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_1)
TestWeekday(rule, Weekday::Monday, Weekday::Friday);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_2)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Weekday_2)
{
Enable(OpeningHoursSerDes::Header::Bits::WeekDay);
@ -258,7 +257,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_2)
TestWeekday(rule, Weekday::Friday, Weekday::Sunday);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_Hours_1)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Weekday_Hours_1)
{
Enable(OpeningHoursSerDes::Header::Bits::WeekDay);
Enable(OpeningHoursSerDes::Header::Bits::Hours);
@ -301,7 +300,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_Hours_1)
}
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Off_SerDes_1_AndUsage)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Off_SerDes_1_AndUsage)
{
SerializeEverything();
EnableAll();
@ -324,7 +323,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Off_SerDes_1_AndUsage)
TEST(oh.IsClosed(GetUnixtimeByDate(2020, Month::Feb, Weekday::Monday, 17 /* hh */, 30 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Off_SerDes_2)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Off_SerDes_2)
{
SerializeEverything();
EnableAll();
@ -360,7 +359,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Off_SerDes_2)
TestModifier(rule, osmoh::RuleSequence::Modifier::Closed);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_OffJustOff)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_OffJustOff)
{
SerializeEverything();
EnableAll();
@ -376,7 +375,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_OffJustOff)
TestModifier(rule, osmoh::RuleSequence::Modifier::Closed);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_OffJustClosed)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_OffJustClosed)
{
SerializeEverything();
EnableAll();
@ -392,7 +391,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_OffJustClosed)
TestModifier(rule, osmoh::RuleSequence::Modifier::Closed);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Open)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Open)
{
SerializeEverything();
EnableAll();
@ -410,7 +409,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Open)
TEST(oh.IsOpen(someMoment), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_TimeIsOver00)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_TimeIsOver00)
{
SerializeEverything();
EnableAll();
@ -428,7 +427,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_TimeIsOver00)
TEST(!oh.IsOpen(GetUnixtimeByDate(2020, Month::Feb, Weekday::Tuesday, 06 /* hh */, 30 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_DefaultOpen)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_DefaultOpen)
{
SerializeEverything();
EnableAll();
@ -446,7 +445,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_DefaultOpen)
TEST(!oh.IsOpen(GetUnixtimeByDate(2020, Month::Feb, Weekday::Sunday, 13 /* hh */, 30 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_SkipRuleOldYear)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_SkipRuleOldYear)
{
SerializeEverything();
EnableAll();
@ -463,7 +462,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_SkipRuleOldYear)
TestTime(rule, 7, 0, 17, 0);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_10_plus)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_10_plus)
{
SerializeEverything();
EnableAll();
@ -487,7 +486,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_10_plus)
TEST(!oh.IsOpen(GetUnixtimeByDate(2020, Month::Mar, Weekday::Saturday, 00 /* hh */, 30 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_24_7)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_24_7)
{
EnableAll();
@ -498,7 +497,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_24_7)
TEST(oh.IsTwentyFourHours(), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_1)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_1)
{
EnableAll();
@ -513,7 +512,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditi
TestMonth(rule, Month::Apr, 1, Month::Jun, 30);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_2)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_2)
{
EnableAll();
@ -528,7 +527,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditi
TestTime(rule, 22, 0, 6, 0);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_3)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_3)
{
EnableAll();
@ -547,7 +546,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditi
TestTime(rule, 21, 30, 7, 0);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_4)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_4)
{
EnableAll();
@ -562,7 +561,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditi
TestMonth(rule, Month::Apr, Month::Oct);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_5)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_5)
{
EnableAll();
@ -582,7 +581,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditi
TestTime(rule, 15, 0, 16, 0);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_6)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_ExamplesFromOsmAccessConditional_6)
{
SerializeEverything();
EnableAll();
@ -602,7 +601,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_ExamplesFromOsmAccessConditi
TestTime(rule, 11, 0, 18, 0);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_EnableForRouting_1)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_EnableForRouting_1)
{
EnableForRouting();
@ -617,7 +616,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_EnableForRouting_1)
TestWeekday(rule, Weekday::Sunday, Weekday::None);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_EnableForRouting_2)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_EnableForRouting_2)
{
EnableForRouting();
@ -669,7 +668,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_EnableForRouting_2)
TestTime(rule, 12, 0, 12, 30);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_WeekdayAndHolidayOff)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_WeekdayAndHolidayOff)
{
SerializeEverything();
EnableAll();
@ -694,7 +693,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_WeekdayAndHolidayOff)
TestModifier(rule, osmoh::RuleSequence::Modifier::Closed);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_WeekDay_OneDay)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_WeekDay_OneDay)
{
EnableAll();
@ -710,7 +709,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_WeekDay_OneDay)
TestTime(rule, 16, 0, 20, 0);
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Hours_Usage_1)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Hours_Usage_1)
{
EnableAll();
@ -723,7 +722,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Hours_Usage_1)
TEST(oh.IsClosed(GetUnixtimeByDate(2020, Month::Feb, Weekday::Monday, 07 /* hh */, 30 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_Usage_1)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Weekday_Usage_1)
{
EnableAll();
@ -736,7 +735,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_Usage_1)
TEST(oh.IsOpen(GetUnixtimeByDate(2020, Month::Feb, Weekday::Wednesday, 17 /* hh */, 30 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_Usage_2)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Weekday_Usage_2)
{
EnableAll();
@ -751,7 +750,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_Usage_2)
TEST(oh.IsClosed(GetUnixtimeByDate(2023, Month::Apr, Weekday::Saturday, 8 /* hh */, 30 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_Usage_3)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Weekday_Usage_3)
{
EnableAll();
@ -764,7 +763,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Weekday_Usage_3)
TEST(oh.IsOpen(GetUnixtimeByDate(2020, Month::Feb, 7, 03 /* hh */, 30 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Month_Usage)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_Month_Usage)
{
EnableAll();
@ -777,7 +776,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_Month_Usage)
TEST(oh.IsClosed(GetUnixtimeByDate(2020, Month::Feb, 5, 17 /* hh */, 30 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_MonthDay_Usage)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_MonthDay_Usage)
{
EnableAll();
@ -793,7 +792,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_MonthDay_Usage)
TEST(oh.IsOpen(GetUnixtimeByDate(2021, Month::Mar, 26, 19 /* hh */, 00 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_MonthDayYear_Usage)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_MonthDayYear_Usage)
{
EnableAll();
@ -809,7 +808,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_MonthDayYear_Usage)
TEST(oh.IsClosed(GetUnixtimeByDate(2052, Month::Mar, 26, 19 /* hh */, 00 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_MonthHours_Usage)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_MonthHours_Usage)
{
EnableAll();
@ -824,7 +823,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_MonthHours_Usage)
TEST(oh.IsOpen(GetUnixtimeByDate(2020, Month::May, 6, 01 /* hh */, 32 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_InverseMonths_Usage_1)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_InverseMonths_Usage_1)
{
EnableAll();
@ -841,7 +840,7 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_InverseMonths_Usage_1)
TEST(!oh.IsOpen(GetUnixtimeByDate(2020, Month::Feb, 20, 20 /* hh */, 00 /* mm */)), ());
}
UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_InverseMonths_Usage_2)
UNIT_CLASS_TEST(OHSerDesTestFixture, OpeningHoursSerDes_InverseMonths_Usage_2)
{
EnableAll();
@ -860,4 +859,4 @@ UNIT_CLASS_TEST(BitReaderWriter, OpeningHoursSerDes_InverseMonths_Usage_2)
TEST(!oh.IsOpen(GetUnixtimeByDate(2020, Month::Apr, 20, 20 /* hh */, 00 /* mm */)), ());
TEST(!oh.IsOpen(GetUnixtimeByDate(2020, Month::May, 20, 20 /* hh */, 00 /* mm */)), ());
}
} // namespace
} // namespace opening_hours_serdes_tests