func TestProcess(t *testing.T) { testForm := NewForm(80, 25, 0) numControls := 10 var processedControls []string for i := 0; i < numControls; i++ { testControl := NewTestControl(fmt.Sprintf("tc%v", i)) testControl.ProcessCallback = func(name string) { processedControls = append(processedControls, name) } testForm.AddControl(testControl, true) } testForm.Process() //Note: process order is not defined for i := 0; i < numControls; i++ { name := fmt.Sprintf("tc%v", i) if algorithms.SearchSliceString(processedControls, name) < 0 { t.Errorf("Did not process %v.", name) } } }
// focusSpecific moves focus to the control with the given name // and sets the tab index to the index of that control. func (form *Form) focusSpecific(controlName string) { form.unfocusCurrentControl() if form.Controls[controlName].Focus() { form.currentTabIndex = algorithms.SearchSliceString(form.TabOrder, controlName) } else { form.currentTabIndex = -1 } }