Exemplo n.º 1
0
        // BUG: only works for the English translation
        public void HashesTest(string name, bool interrupt, string def_expected_results, string full_expected_results)
        {
            // Reset the selected checksums back to the default
            RegistryKey reg_key = Registry.CurrentUser.OpenSubKey("SOFTWARE");

            reg_key = reg_key.OpenSubKey("HashCheck", true);  // (true == with-write-access)
            if (reg_key != null)
            {
                reg_key.DeleteValue("Checksums", false);  // (false == no-exceptions-if-not-found)
            }
            Window prop_window = OpenHashPropWindow(name);

            try
            {
                VerifyResults(prop_window, def_expected_results);

                // If we should try to interrupt hash calculation in-progress, restart it
                // (VerifyResults() above waits for completion, the following does not)
                if (interrupt)
                {
                    prop_window.Close();
                    prop_window = null;
                    prop_window = OpenHashPropWindow(name);
                }

                // Open the options dialog
                prop_window.Get <Button>("Options").Click();
                Window options_window = null;
                while (true)
                {
                    foreach (Window mw in prop_window.ModalWindows())
                    {
                        if (mw.Name.StartsWith("HashCheck Options"))
                        {
                            options_window = mw;
                            goto options_window_found;
                        }
                    }
                    System.Threading.Thread.Sleep(0);
                }
options_window_found:

                // Enable all the hash option checkboxes and click OK
                foreach (CheckBox cb in options_window.GetMultiple(SearchCriteria.ByControlType(ControlType.CheckBox)))
                {
                    cb.State = ToggleState.On;
                }
                options_window.Get <Button>("OK").Click();

                VerifyResults(prop_window, full_expected_results);
            }
            finally
            {
                if (prop_window != null)
                {
                    prop_window.Close();
                }
            }
        }