Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into LocationAccuracyHandling
Browse files Browse the repository at this point in the history
  • Loading branch information
jfversluis authored Jul 3, 2023
2 parents 96b69b4 + 8ee188f commit a288214
Show file tree
Hide file tree
Showing 54 changed files with 1,042 additions and 207 deletions.
7 changes: 4 additions & 3 deletions .openpublishing.publish.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@
}
],
"notification_subscribers": [],
"sync_notification_subscribers": null,
"branches_to_filter": [],
"skip_source_output_uploading": false,
"need_preview_pull_request": false,
"contribution_branch_mappings": {},
"need_pr_comments": false,
"contribution_branch_mappings": {},
"dependent_repositories": [
{
"path_to_root": "_themes",
"url": "https://github.com/Microsoft/templates.docs.msft",
"branch": "master",
"branch": "main",
"branch_mapping": {}
}
],
Expand All @@ -84,4 +85,4 @@
"docs_build_engine": {
"name": "docfx_v3"
}
}
}
11 changes: 6 additions & 5 deletions DeviceTests/DeviceTests.Android/DeviceTests.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<RootNamespace>DeviceTests.Droid</RootNamespace>
<AssemblyName>XamarinEssentialsDeviceTestsAndroid</AssemblyName>
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>
<AndroidApplication>True</AndroidApplication>
<AndroidUseIntermediateDesignerFile>true</AndroidUseIntermediateDesignerFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
Expand All @@ -19,6 +19,7 @@
<AndroidUseAapt2>true</AndroidUseAapt2>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64;arm64-v8a</AndroidSupportedAbis>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -57,13 +58,13 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.5.25" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.21620.1" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0.1" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.6" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.23212.1" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.15" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Xamarin.Essentials\Xamarin.Essentials.csproj">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0.1.0" package="com.xamarin.essentials.devicetests" android:installLocation="auto">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="33" />
<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
Expand Down Expand Up @@ -41,5 +42,5 @@
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/MainTheme"></application>
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:theme="@style/MainTheme"></application>
</manifest>
8 changes: 4 additions & 4 deletions DeviceTests/DeviceTests.Shared/DeviceTests.Shared.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.22">
<PropertyGroup>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">Xamarin.iOS10;MonoAndroid10.0;uap10.0.16299</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">Xamarin.iOS10;MonoAndroid10.0;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">Xamarin.iOS10;MonoAndroid13.0;uap10.0.16299</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">Xamarin.iOS10;MonoAndroid13.0;</TargetFrameworks>
<AssemblyName>XamarinEssentialsDeviceTestsShared</AssemblyName>
<RootNamespace>DeviceTests.Shared</RootNamespace>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
Expand All @@ -13,6 +13,7 @@
<DefineConstants>$(DefineConstants);</DefineConstants>
<MDocDocumentationDirectory>$(MSBuildThisFileDirectory)..\docs\en</MDocDocumentationDirectory>
<Configurations>Debug;Release</Configurations>
<BuildWithMSBuildOnMono>true</BuildWithMSBuildOnMono>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
<DebugType>full</DebugType>
Expand All @@ -23,11 +24,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.5.25" />
<PackageReference Include="UnitTests.HeadlessRunner" Version="2.0.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<ProjectReference Include="..\..\Xamarin.Essentials\Xamarin.Essentials.csproj" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('uap10.0')) ">
Expand Down
146 changes: 146 additions & 0 deletions DeviceTests/DeviceTests.Shared/VersionTracking_Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
using System;
using System.Diagnostics;
using Xamarin.Essentials;
using Xunit;
using Xunit.Abstractions;

namespace DeviceTests
{
public class VersionTracking_Tests
{
/// <summary>
/// We cannot mock the app version but it should be constant value
/// </summary>
const string currentVersion = "1.0.1.0";
const string currentBuild = "1";

const string versionTrailKey = "VersionTracking.Trail";
const string versionsKey = "VersionTracking.Versions";
const string buildsKey = "VersionTracking.Builds";
static readonly string sharedName = Preferences.GetPrivatePreferencesSharedName("versiontracking");

readonly ITestOutputHelper output;

public VersionTracking_Tests(ITestOutputHelper output)
{
this.output = output;
}

[Fact]
public void First_Launch_Ever()
{
VersionTracking.Track();
Preferences.Clear(sharedName);

VersionTracking.InitVersionTracking();

Assert.Equal(currentVersion, VersionTracking.CurrentVersion);
Assert.True(VersionTracking.IsFirstLaunchEver);
Assert.True(VersionTracking.IsFirstLaunchForCurrentVersion);
Assert.True(VersionTracking.IsFirstLaunchForCurrentBuild);
}

[Fact]
public void First_Launch_For_Version()
{
VersionTracking.Track();
Preferences.Set(versionsKey, string.Join("|", new string[] { "0.8.0", "0.9.0", "1.0.0" }), sharedName);
Preferences.Set(buildsKey, string.Join("|", new string[] { currentBuild }), sharedName);

VersionTracking.InitVersionTracking();

Assert.Equal(currentVersion, VersionTracking.CurrentVersion);
Assert.Equal("1.0.0", VersionTracking.PreviousVersion);
Assert.Equal("0.8.0", VersionTracking.FirstInstalledVersion);
Assert.False(VersionTracking.IsFirstLaunchEver);
Assert.True(VersionTracking.IsFirstLaunchForCurrentVersion);
Assert.False(VersionTracking.IsFirstLaunchForCurrentBuild);

VersionTracking.InitVersionTracking();

Assert.Equal(currentVersion, VersionTracking.CurrentVersion);
Assert.Equal("1.0.0", VersionTracking.PreviousVersion);
Assert.Equal("0.8.0", VersionTracking.FirstInstalledVersion);
Assert.False(VersionTracking.IsFirstLaunchEver);
Assert.False(VersionTracking.IsFirstLaunchForCurrentVersion);
Assert.False(VersionTracking.IsFirstLaunchForCurrentBuild);
}

[Fact]
public void First_Launch_For_Build()
{
VersionTracking.Track();
Preferences.Set(versionsKey, string.Join("|", new string[] { currentVersion }), sharedName);
Preferences.Set(buildsKey, string.Join("|", new string[] { "10", "20" }), sharedName);

VersionTracking.InitVersionTracking();

Assert.Equal(currentVersion, VersionTracking.CurrentVersion);
Assert.Equal("20", VersionTracking.PreviousBuild);
Assert.Equal("10", VersionTracking.FirstInstalledBuild);
Assert.False(VersionTracking.IsFirstLaunchEver);
Assert.False(VersionTracking.IsFirstLaunchForCurrentVersion);
Assert.True(VersionTracking.IsFirstLaunchForCurrentBuild);

VersionTracking.InitVersionTracking();

Assert.Equal(currentVersion, VersionTracking.CurrentVersion);
Assert.Equal("20", VersionTracking.PreviousBuild);
Assert.Equal("10", VersionTracking.FirstInstalledBuild);
Assert.False(VersionTracking.IsFirstLaunchEver);
Assert.False(VersionTracking.IsFirstLaunchForCurrentVersion);
Assert.False(VersionTracking.IsFirstLaunchForCurrentBuild);
}

[Fact]
public void First_Launch_After_Downgrade()
{
VersionTracking.Track();
Preferences.Set(versionsKey, string.Join("|", new string[] { currentVersion, "1.0.2", "1.0.3" }), sharedName);

VersionTracking.InitVersionTracking();
output.WriteLine(VersionTracking.GetStatus());

Assert.Equal(currentVersion, VersionTracking.CurrentVersion);
Assert.Equal("1.0.3", VersionTracking.PreviousVersion);
Assert.Equal("1.0.2", VersionTracking.FirstInstalledVersion);
Assert.False(VersionTracking.IsFirstLaunchEver);
Assert.True(VersionTracking.IsFirstLaunchForCurrentVersion);

VersionTracking.InitVersionTracking();

Assert.Equal(currentVersion, VersionTracking.CurrentVersion);
Assert.Equal("1.0.3", VersionTracking.PreviousVersion);
Assert.Equal("1.0.2", VersionTracking.FirstInstalledVersion);
Assert.False(VersionTracking.IsFirstLaunchEver);
Assert.False(VersionTracking.IsFirstLaunchForCurrentVersion);
}

[Fact]
public void First_Launch_After_Build_Downgrade()
{
VersionTracking.Track();
Preferences.Set(versionsKey, string.Join("|", new string[] { currentVersion }), sharedName);
Preferences.Set(buildsKey, string.Join("|", new string[] { currentBuild, "10", "20" }), sharedName);

VersionTracking.InitVersionTracking();
output.WriteLine(VersionTracking.GetStatus());

Assert.Equal(currentBuild, VersionTracking.CurrentBuild);
Assert.Equal("20", VersionTracking.PreviousBuild);
Assert.Equal("10", VersionTracking.FirstInstalledBuild);
Assert.False(VersionTracking.IsFirstLaunchEver);
Assert.False(VersionTracking.IsFirstLaunchForCurrentVersion);
Assert.True(VersionTracking.IsFirstLaunchForCurrentBuild);

VersionTracking.InitVersionTracking();

Assert.Equal(currentBuild, VersionTracking.CurrentBuild);
Assert.Equal("20", VersionTracking.PreviousBuild);
Assert.Equal("10", VersionTracking.FirstInstalledBuild);
Assert.False(VersionTracking.IsFirstLaunchEver);
Assert.False(VersionTracking.IsFirstLaunchForCurrentVersion);
Assert.False(VersionTracking.IsFirstLaunchForCurrentBuild);
}
}
}
2 changes: 1 addition & 1 deletion DeviceTests/DeviceTests.UWP/DeviceTests.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="UnitTests.HeadlessRunner" Version="2.0.0" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.9" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.5.25" />
Expand Down
4 changes: 2 additions & 2 deletions DeviceTests/DeviceTests.iOS/DeviceTests.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.5.25" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.21620.1" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.23212.1" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions DeviceTests/DeviceTests.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,9 @@
<string>Access to your location is required for cool things to happen!</string>
<key>NSContactsUsageDescription</key>
<string>Contacts</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
</dict>
</plist>
Loading

0 comments on commit a288214

Please sign in to comment.