public void OriginalFilesModificationTest(string version, string fileName)
        {
            var mockIOProvider    = BackCompatTestProperties.GetModuleIOProvider(version, PowerLauncherSettings.ModuleName, fileName);
            var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object);
            PowerLauncherSettings originalSettings = mockSettingsUtils.GetSettings <PowerLauncherSettings>(PowerLauncherSettings.ModuleName);

            var             mockGeneralIOProvider     = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
            var             mockGeneralSettingsUtils  = new SettingsUtils(mockGeneralIOProvider.Object);
            GeneralSettings originalGeneralSettings   = mockGeneralSettingsUtils.GetSettings <GeneralSettings>();
            var             generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository <GeneralSettings>(mockGeneralSettingsUtils);

            // Initialise View Model with test Config files
            Func <string, int>     SendMockIPCConfigMSG = msg => { return(0); };
            PowerLauncherViewModel viewModel            = new PowerLauncherViewModel(mockSettingsUtils, generalSettingsRepository, SendMockIPCConfigMSG, 32);

            // Verifiy that the old settings persisted
            Assert.AreEqual(originalGeneralSettings.Enabled.PowerLauncher, viewModel.EnablePowerLauncher);
            Assert.AreEqual(originalSettings.Properties.ClearInputOnLaunch, viewModel.ClearInputOnLaunch);
            Assert.AreEqual(originalSettings.Properties.CopyPathLocation.ToString(), viewModel.CopyPathLocation.ToString());
            Assert.AreEqual(originalSettings.Properties.DisableDriveDetectionWarning, viewModel.DisableDriveDetectionWarning);
            Assert.AreEqual(originalSettings.Properties.IgnoreHotkeysInFullscreen, viewModel.IgnoreHotkeysInFullScreen);
            Assert.AreEqual(originalSettings.Properties.MaximumNumberOfResults, viewModel.MaximumNumberOfResults);
            Assert.AreEqual(originalSettings.Properties.OpenPowerLauncher.ToString(), viewModel.OpenPowerLauncher.ToString());
            Assert.AreEqual(originalSettings.Properties.OverrideWinkeyR, viewModel.OverrideWinRKey);
            Assert.AreEqual(originalSettings.Properties.OverrideWinkeyS, viewModel.OverrideWinSKey);
            Assert.AreEqual(originalSettings.Properties.SearchResultPreference, viewModel.SearchResultPreference);
            Assert.AreEqual(originalSettings.Properties.SearchTypePreference, viewModel.SearchTypePreference);

            //Verify that the stub file was used
            var expectedCallCount = 2;  //once via the view model, and once by the test (GetSettings<T>)

            BackCompatTestProperties.VerifyModuleIOProviderWasRead(mockIOProvider, PowerLauncherSettings.ModuleName, expectedCallCount);
            BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralIOProvider, expectedCallCount);
        }
Exemplo n.º 2
0
 public void Initialize()
 {
     mockSettings     = new PowerLauncherSettings();
     sendCallbackMock = new SendCallbackMock();
     viewModel        = new PowerLauncherViewModel(
         mockSettings,
         new PowerLauncherViewModel.SendCallback(sendCallbackMock.OnSend));
 }
Exemplo n.º 3
0
        public PowerLauncherPage()
        {
            InitializeComponent();
            var settingsUtils = new SettingsUtils();

            _lastIPCMessageSentTick = Environment.TickCount;
            PowerLauncherSettings settings = settingsUtils.GetSettingsOrDefault <PowerLauncherSettings>(PowerLauncherSettings.ModuleName);

            ViewModel   = new PowerLauncherViewModel(settings, SettingsRepository <GeneralSettings> .GetInstance(settingsUtils), SendDefaultIPCMessageTimed, App.IsDarkTheme);
            DataContext = ViewModel;
            _           = Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", () =>
            {
                if (Environment.TickCount < _lastIPCMessageSentTick + 500)
                {
                    // Don't try to update data from the file if we tried to write to it through IPC in the last 500 milliseconds.
                    return;
                }

                PowerLauncherSettings powerLauncherSettings = null;
                try
                {
                    powerLauncherSettings = settingsUtils.GetSettingsOrDefault <PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
                }
                catch (IOException ex)
                {
                    Logger.LogInfo(ex.Message);
                }

                if (powerLauncherSettings != null && !ViewModel.IsUpToDate(powerLauncherSettings))
                {
                    _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        DataContext = ViewModel = new PowerLauncherViewModel(powerLauncherSettings, SettingsRepository <GeneralSettings> .GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, App.IsDarkTheme);
                        this.Bindings.Update();
                    });
                }
            });

            var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

            searchResultPreferencesOptions = new ObservableCollection <Tuple <string, string> >();
            searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_AlphabeticalOrder"), "alphabetical_order"));
            searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_MostRecentlyUsed"), "most_recently_used"));
            searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_RunningProcessesOpenApplications"), "running_processes_open_applications"));

            searchTypePreferencesOptions = new ObservableCollection <Tuple <string, string> >();
            searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ApplicationName"), "application_name"));
            searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_StringInApplication"), "string_in_application"));
            searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ExecutableName"), "executable_name"));
        }
Exemplo n.º 4
0
        public PowerLauncherPage()
        {
            InitializeComponent();
            ViewModel   = new PowerLauncherViewModel(ShellPage.SendDefaultIPCMessage, (int)Windows.System.VirtualKey.Space);
            DataContext = ViewModel;

            var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

            searchResultPreferencesOptions = new ObservableCollection <Tuple <string, string> >();
            searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_AlphabeticalOrder"), "alphabetical_order"));
            searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_MostRecentlyUsed"), "most_recently_used"));
            searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_RunningProcessesOpenApplications"), "running_processes_open_applications"));

            searchTypePreferencesOptions = new ObservableCollection <Tuple <string, string> >();
            searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ApplicationName"), "application_name"));
            searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_StringInApplication"), "string_in_application"));
            searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ExecutableName"), "executable_name"));
        }
Exemplo n.º 5
0
        public PowerLauncherPage()
        {
            InitializeComponent();
            var settingsUtils = new SettingsUtils();
            PowerLauncherSettings settings = settingsUtils.GetSettingsOrDefault <PowerLauncherSettings>(PowerLauncherSettings.ModuleName);

            ViewModel   = new PowerLauncherViewModel(settings, SettingsRepository <GeneralSettings> .GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, App.IsDarkTheme);
            DataContext = ViewModel;
            _           = Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", () =>
            {
                _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    PowerLauncherSettings powerLauncherSettings = null;
                    try
                    {
                        powerLauncherSettings = settingsUtils.GetSettingsOrDefault <PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
                    }
                    catch (IOException ex)
                    {
                        Logger.LogInfo(ex.Message);
                    }

                    if (powerLauncherSettings != null)
                    {
                        DataContext = ViewModel = new PowerLauncherViewModel(powerLauncherSettings, SettingsRepository <GeneralSettings> .GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, App.IsDarkTheme);
                        this.Bindings.Update();
                    }
                });
            });

            var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

            searchResultPreferencesOptions = new ObservableCollection <Tuple <string, string> >();
            searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_AlphabeticalOrder"), "alphabetical_order"));
            searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_MostRecentlyUsed"), "most_recently_used"));
            searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_RunningProcessesOpenApplications"), "running_processes_open_applications"));

            searchTypePreferencesOptions = new ObservableCollection <Tuple <string, string> >();
            searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ApplicationName"), "application_name"));
            searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_StringInApplication"), "string_in_application"));
            searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ExecutableName"), "executable_name"));
        }