AndroidLogcatView { @VisibleForTesting void updateDefaultFilters(@Nullable ClientData client) { int noFilterIndex = myFilterComboBoxModel.getIndexOf(NO_FILTERS_ITEM); for (int i = 0; i < noFilterIndex; i++) { myFilterComboBoxModel.removeElementAt(0); } AndroidLogcatFilter filter = client == null ? FAKE_SHOW_ONLY_SELECTED_APPLICATION_FILTER : new SelectedProcessFilter(client.getPid()); int insertIndex = 0; myFilterComboBoxModel.insertElementAt(filter, insertIndex++); for (LogcatFilterProvider filterProvider : LogcatFilterProvider.EP_NAME.getExtensions()) { myFilterComboBoxModel.insertElementAt(filterProvider.getFilter(client), insertIndex++); } } AndroidLogcatView(@NotNull Project project, @NotNull DeviceContext deviceContext, @NotNull Disposable parentDisposable); @NotNull final Project getProject(); @NotNull final AndroidLogConsole getLogConsole(); @NotNull Component createEditFiltersComboBox(); final void activate(); @NotNull final JPanel getContentPanel(); static final Key<AndroidLogcatView> ANDROID_LOGCAT_VIEW_KEY; }
@Test public void updateDefaultFilters() { myLogcatView.createEditFiltersComboBox(); myLogcatView.updateDefaultFilters(null); ListModel<AndroidLogcatFilter> model = myLogcatView.getEditFiltersComboBoxModel(); assertEquals(3, model.getSize()); int index = 0; assertEquals(AndroidLogcatView.FAKE_SHOW_ONLY_SELECTED_APPLICATION_FILTER, model.getElementAt(index++)); assertEquals(AndroidLogcatView.NO_FILTERS_ITEM, model.getElementAt(index++)); assertEquals(AndroidLogcatView.EDIT_FILTER_CONFIGURATION_ITEM, model.getElementAt(index++)); }