void CheckListContainsProjectLocales(WrapperWindow wnd) { var listScrollView = wnd.rootVisualElement.Q <ReorderableList>().Q <ScrollView>(); var locales = LocalizationEditorSettings.GetLocales().ToList(); Assert.AreEqual(locales.Count, listScrollView.childCount, "Expected list size to match the number of project locales."); int localeCount = locales.Count; for (int i = 0; i < localeCount; ++i) { var item = listScrollView[i]; var name = item.Q <TextField>("name"); var code = item.Q <TextField>("code"); Assert.NotNull(name, "Could not find name field."); Assert.NotNull(code, "Could not find code field."); var matchingLocale = locales.FirstOrDefault(l => l.name == name.value); Assert.NotNull(matchingLocale, $"Could not find a matching locale for {name.value}({code.value})"); locales.Remove(matchingLocale); } Assert.That(locales, Is.Empty, "Expected all project locales to be in the ListView but they were not."); }
public IEnumerator ListViewUpdatesWhenLocaleIsAdded() { bool localeAdded = false; WrapperWindow window = GetWindow((wnd) => { // Add a new Locale if (!localeAdded) { var newLocale = Locale.CreateLocale(SystemLanguage.Hebrew); LocalizationEditorSettings.AddLocale(newLocale); Assert.That(m_FakeLocaleProvider.TestLocales, Does.Contain(newLocale)); localeAdded = true; return(false); } else { CheckListContainsProjectLocales(wnd); return(true); } }); var root = m_PropertyDrawer.CreatePropertyGUI(m_ScriptableObject.FindProperty("provider")); window.rootVisualElement.Add(root); yield return(null); Assert.That(window.TestCompleted, Is.True); }
private void Button_Click(object sender, RoutedEventArgs e) { var fileName = System.IO.Path.Combine(Environment.SystemDirectory, "notepad.exe"); var wrapperWindow = new WrapperWindow(fileName); wrapperWindow.ShowDialog(); }
public IEnumerator ListViewUpdatesWhenLocaleIsRemoved() { WrapperWindow window = GetWindow((wnd) => { // Perform an update var height = m_PropertyDrawer.GetPropertyHeight(m_Property, GUIContent.none); m_PropertyDrawer.OnGUI(new Rect(0, 0, 1000, height), m_Property, GUIContent.none); // Remove a locale var localeToRemove = m_FakeLocaleProvider.TestLocales[0]; LocalizationEditorSettings.RemoveLocale(localeToRemove); Assert.That(m_FakeLocaleProvider.TestLocales, Does.Not.Contains(localeToRemove)); // Update again, it should not contain the new element height = m_PropertyDrawer.GetPropertyHeight(m_Property, GUIContent.none); m_PropertyDrawer.OnGUI(new Rect(0, 0, 1000, height), m_Property, GUIContent.none); CheckListViewContainsProjectLocales(); return(true); }); yield return(null); Assert.That(window.TestCompleted, Is.True); }
public IEnumerator ListViewUpdatesWhenLocaleIsAdded() { WrapperWindow window = GetWindow((wnd) => { // Perform an update var height = m_PropertyDrawer.GetPropertyHeight(m_Property, GUIContent.none); m_PropertyDrawer.OnGUI(new Rect(wnd.position.x, wnd.position.y, wnd.position.width, height), m_Property, GUIContent.none); // Add a new Locale var newLocale = Locale.CreateLocale(SystemLanguage.Hebrew); LocalizationEditorSettings.AddLocale(newLocale); // Update again, it should not contain the new element height = m_PropertyDrawer.GetPropertyHeight(m_Property, GUIContent.none); m_PropertyDrawer.OnGUI(new Rect(wnd.position.x, wnd.position.y, wnd.position.width, height), m_Property, GUIContent.none); Assert.That(m_FakeLocaleProvider.TestLocales, Does.Contain(newLocale)); CheckListViewContainsProjectLocales(); return(true); }); yield return(null); Assert.That(window.TestCompleted, Is.True); }
public void CloseMostRecentWrapperWindow() { if (s_MostRecentWrapperWindow == null) { return; } s_MostRecentWrapperWindow.Close(); s_MostRecentWrapperWindow = null; }
public IEnumerator ListViewContainsAllProjectLocales() { WrapperWindow window = GetWindow((wnd) => { CheckListContainsProjectLocales(wnd); return(true); }); var root = m_PropertyDrawer.CreatePropertyGUI(m_ScriptableObject.FindProperty("provider")); window.rootVisualElement.Add(root); yield return(null); Assert.That(window.TestCompleted, Is.True); }
public IEnumerator ListViewContainsAllProjectLocales() { WrapperWindow window = GetWindow((wnd) => { // Perform an update var height = m_PropertyDrawer.GetPropertyHeight(m_Property, GUIContent.none); m_PropertyDrawer.OnGUI(new Rect(wnd.position.x, wnd.position.y, wnd.position.width, height), m_Property, GUIContent.none); CheckListViewContainsProjectLocales(); return(true); }); yield return(null); Assert.That(window.TestCompleted, Is.True); }
public IEnumerator ListViewUpdatesWhenLocaleIsRemoved() { WrapperWindow window = GetWindow((wnd) => { // Remove a locale var localeToRemove = m_FakeLocaleProvider.TestLocales[0]; LocalizationEditorSettings.RemoveLocale(localeToRemove); Assert.That(m_FakeLocaleProvider.TestLocales, Does.Not.Contains(localeToRemove)); CheckListContainsProjectLocales(wnd); return(true); }); var root = m_PropertyDrawer.CreatePropertyGUI(m_ScriptableObject.FindProperty("provider")); window.rootVisualElement.Add(root); yield return(null); Assert.That(window.TestCompleted, Is.True); }
public static WrapperWindow GetWindow(Func <WrapperWindow, bool> onGUIDelegate, int width, int height, bool utility = false) { WrapperWindow window; if (utility) { window = EditorWindow.GetWindow <WrapperWindow>(true); } else { window = ScriptableObject.CreateInstance <WrapperWindow>(); window.hideFlags = HideFlags.DontSave; } window.onGUIDelegate = onGUIDelegate; window.position = new Rect(0, 0, width, height); window.Show(); s_MostRecentWrapperWindow = window; return(window); }
private static void ShowResultsInApp(EPIEvaluator appProtoModelEval, ApplicationProtocolClassificationStatisticsMeter epiprecMeasure, ApplicationProtocolClassificationStatisticsMeter mlprecMeasure) { WrapperWindow mainView = null; var t = new Thread(() => { mainView = new WrapperWindow { DataContext = new AppIdentMainVm(appProtoModelEval, epiprecMeasure, mlprecMeasure) }; // Initiates the dispatcher thread shutdown when the mainView closes mainView.Closed += (s, e) => mainView.Dispatcher.InvokeShutdown(); mainView.Show(); // Makes the thread support message pumping System.Windows.Threading.Dispatcher.Run(); }); // Configure the thread t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); }
protected static void RegisterWrapperWindow(WrapperWindow window) { s_MostRecentWrapperWindow = window; }