* check if entered URI looks like a directory (not a file) and issue warning in SelectStorageLocationActivity

* check if URI is directory and refuse to delete in IOConnection
This commit is contained in:
Philipp Crocoll
2015-06-17 06:33:29 +02:00
parent 6c3795ff1a
commit ed15af3f8f
12 changed files with 127 additions and 35 deletions

View File

@@ -14,12 +14,13 @@
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<TargetFrameworkVersion>v4.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.4</TargetFrameworkVersion>
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
<AndroidStoreUncompressedFileExtensions />
<MandroidI18n />
<JavaMaximumHeapSize />
<JavaOptions />
<AndroidUseLatestPlatformSdk />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -101,7 +102,7 @@
<Name>KeePassLib2Android</Name>
</ProjectReference>
<ProjectReference Include="..\Kp2aBusinessLogic\Kp2aBusinessLogic.csproj">
<Project>{53A9CB7F-6553-4BC0-B56B-9410BB2E59AA}</Project>
<Project>{53a9cb7f-6553-4bc0-b56b-9410bb2e59aa}</Project>
<Name>Kp2aBusinessLogic</Name>
</ProjectReference>
<ProjectReference Include="..\KP2AKdbLibraryBinding\KP2AKdbLibraryBinding.csproj">

View File

@@ -23,7 +23,7 @@ namespace Kp2aUnitTests
//runner.AddTests(typeof(TestLoadDb).GetMethod("TestLoadKdb1WithKeyfileOnly"));
//runner.AddTests(new List<Type> { typeof(TestSelectStorageLocation) });
runner.AddTests(new List<Type> { typeof(TestSelectStorageLocation) });
//runner.AddTests(new List<Type> { typeof(TestSynchronizeCachedDatabase)});
//runner.AddTests(typeof(TestLoadDb).GetMethod("LoadErrorWithCertificateTrustFailure"));
//runner.AddTests(typeof(TestLoadDb).GetMethod("LoadWithAcceptedCertificateTrustFailure"));
@@ -36,7 +36,7 @@ namespace Kp2aUnitTests
//runner.AddTests(typeof(TestSaveDb).GetMethod("TestLoadAndSave_TestIdenticalFiles_kdb"));
//runner.AddTests(typeof(TestSaveDb).GetMethod("TestCreateSaveAndLoad_TestIdenticalFiles_kdb"));
runner.AddTests(typeof(TestSaveDb).GetMethod("TestSaveTwice_kdb"));
// runner.AddTests(typeof(TestSaveDb).GetMethod("TestSaveTwice_kdb"));
//runner.AddTests(typeof(TestLoadDb).GetMethod("LoadAndSaveFromRemote1And1Ftp"));
//runner.AddTests(typeof(TestLoadDb).GetMethod("TestLoadKdbpWithPasswordOnly"));

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
<application></application>
</manifest>

View File

@@ -225,6 +225,12 @@ namespace Kp2aUnitTests
_userAction = new SelectFileAction(isForSave, browseRequestCode, protocolId, this);
}
protected override void ShowFilenameWarning(string fileName, Action onUserWantsToContinue, Action onUserWantsToCorrect)
{
_userAction = new ShowAlertDialogAction("filenameWarning", delegate { onUserWantsToContinue(); },
delegate { onUserWantsToCorrect(); });
}
public void HandleActivityResult(int requestCode, Result resultCode, Intent data)
{
OnActivityResult(requestCode, resultCode, data);
@@ -281,7 +287,7 @@ namespace Kp2aUnitTests
private void PressOpenButton(string path, int browseRequestCode)
{
OnOpenButton(path, browseRequestCode);
OnOpenButton(path, browseRequestCode, () => { });
}
@@ -523,6 +529,48 @@ namespace Kp2aUnitTests
}
[TestMethod]
public void TestManualSelectWithDirectoryCancel()
{
var testee = CreateTestee();
var action = (TestControllableSelectStorageLocationActivity.FileStorageSelectionAction)testee._userAction;
action.ReturnProtocol("ftp");
Assert.IsNull(testee._result); //no result yet
var action2 = (TestControllableSelectStorageLocationActivity.SelectFileAction)testee._userAction;
string path = "ftp://crocoll.net/";
action2.PerformManualFileSelect(path);
Assert.IsNull(testee._result);
var action3 = (TestControllableSelectStorageLocationActivity.ShowAlertDialogAction) testee._userAction;
action3.Ok();
Assert.IsTrue((bool)testee._result);
Assert.AreEqual(testee._resultIoc.Path, path);
}
[TestMethod]
public void TestManualSelectWithDirectory()
{
var testee = CreateTestee();
var action = (TestControllableSelectStorageLocationActivity.FileStorageSelectionAction)testee._userAction;
action.ReturnProtocol("ftp");
Assert.IsNull(testee._result); //no result yet
var action2 = (TestControllableSelectStorageLocationActivity.SelectFileAction)testee._userAction;
string path = "ftp://crocoll.net/";
action2.PerformManualFileSelect(path);
Assert.IsNull(testee._result);
var action3 = (TestControllableSelectStorageLocationActivity.ShowAlertDialogAction)testee._userAction;
action3.Cancel();
}
[TestMethod]
public void TestCancelManualSelect()
{