Drive Detection Indexer warning refinement (#5221)

* show results always and conditionally show warning

* changed test logic to show warning when expected

* renamed unit test
This commit is contained in:
Alekhya 2020-07-24 17:45:07 -07:00 committed by GitHub
parent 563fb3ff5c
commit 025f2507f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 83 additions and 85 deletions

View File

@ -18,10 +18,10 @@ namespace Microsoft.Plugin.Indexer.DriveDetection
GetEnhancedModeStatus();
}
// To display the results if either enhanced mode is on or if the disable drive detection checkbox is checked
public bool DisplayResults()
// To display the warning when Enhanced mode is disabled and the Disable Drive detection check box in settings is unchecked
public bool DisplayWarning()
{
return IsDriveDetectionWarningCheckBoxSelected || IsEnhancedModeEnabled;
return !(IsDriveDetectionWarningCheckBoxSelected || IsEnhancedModeEnabled);
}
// To look up the registry entry for

View File

@ -52,8 +52,6 @@ namespace Microsoft.Plugin.Indexer
{
var results = new List<Result>();
if (_driveDetection.DisplayResults())
{
if (!string.IsNullOrEmpty(query.Search))
{
var searchQuery = query.Search;
@ -68,6 +66,28 @@ namespace Microsoft.Plugin.Indexer
{
try
{
if(_driveDetection.DisplayWarning())
{
results.Add(new Result
{
Title = _context.API.GetTranslation("Microsoft_plugin_indexer_drivedetectionwarning"),
SubTitle = _context.API.GetTranslation("Microsoft_plugin_indexer_disable_warning_in_settings"),
IcoPath = WarningIconPath,
Action = e =>
{
try
{
Process.Start(GetWindowsSearchSettingsProcessInfo());
}
catch (Exception ex)
{
Log.Exception("Microsoft.Plugin.Indexer", $"Unable to launch Windows Search Settings: {ex.Message}", ex, "Query");
}
return true;
}
});
}
var searchResultsList = _api.Search(searchQuery, maxCount: _settings.MaxSearchCount).ToList();
foreach (var searchResult in searchResultsList)
{
@ -127,28 +147,6 @@ namespace Microsoft.Plugin.Indexer
}
}
}
}
else
{
results.Add(new Result
{
Title = _context.API.GetTranslation("Microsoft_plugin_indexer_drivedetectionwarning"),
SubTitle = _context.API.GetTranslation("Microsoft_plugin_indexer_disable_warning_in_settings"),
IcoPath = WarningIconPath,
Action = e =>
{
try
{
Process.Start(GetWindowsSearchSettingsProcessInfo());
}
catch (Exception ex)
{
Log.Exception("Microsoft.Plugin.Indexer", $"Unable to launch Windows Search Settings: {ex.Message}", ex, "Query");
}
return true;
}
});
}
return results;
}

View File

@ -299,11 +299,11 @@ namespace Wox.Test.Plugins
mockapi.Verify(m => m.GetTranslation("Microsoft_plugin_indexer_open_in_console"), Times.Once());
}
[TestCase(0, false, ExpectedResult = false)]
[TestCase(0, true, ExpectedResult = true)]
[TestCase(1, false, ExpectedResult = true)]
[TestCase(1, true, ExpectedResult = true)]
public bool DriveDetection_MustDisplayResults_WhenEnhancedModeIsOnOrWhenWarningIsDisabled(int enhancedModeStatus, bool disableWarningCheckBoxStatus)
[TestCase(0, false, ExpectedResult = true)]
[TestCase(0, true, ExpectedResult = false)]
[TestCase(1, false, ExpectedResult = false)]
[TestCase(1, true, ExpectedResult = false)]
public bool DriveDetection_MustDisplayWarning_WhenEnhancedModeIsOffAndWhenWarningIsNotDisabled(int enhancedModeStatus, bool disableWarningCheckBoxStatus)
{
// Arrange
var mockRegistry = new Mock<IRegistryWrapper>();
@ -313,7 +313,7 @@ namespace Wox.Test.Plugins
_driveDetection.IsDriveDetectionWarningCheckBoxSelected = disableWarningCheckBoxStatus;
// Act & Assert
return _driveDetection.DisplayResults();
return _driveDetection.DisplayWarning();
}
}