-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathTitleBarButtonControllerTest.java
More file actions
63 lines (52 loc) · 2.27 KB
/
TitleBarButtonControllerTest.java
File metadata and controls
63 lines (52 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.reactnativenavigation.viewcontrollers.stack;
import android.app.Activity;
import android.view.MenuItem;
import com.reactnativenavigation.BaseTest;
import com.reactnativenavigation.mocks.ImageLoaderMock;
import com.reactnativenavigation.mocks.TitleBarButtonCreatorMock;
import com.reactnativenavigation.options.ButtonOptions;
import com.reactnativenavigation.options.params.Text;
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController;
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter;
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver;
import com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import static org.assertj.core.api.Java6Assertions.assertThat;
public class TitleBarButtonControllerTest extends BaseTest {
private ButtonController uut;
private ButtonBar titleBar;
@Override
public void beforeEach() {
super.beforeEach();
Activity activity = newActivity();
titleBar = new ButtonBar(activity);
ButtonOptions button = createComponentButton();
uut = new ButtonController(
activity,
new ButtonPresenter(activity, button, new IconResolver(activity, ImageLoaderMock.mock())),
button,
new TitleBarButtonCreatorMock(),
Mockito.mock(ButtonController.OnClickListener.class)
);
}
@Test
public void addToMenu_componentButtonIsNotRecreatedIfAlreadyAddedWithSameOrder() {
uut.addToMenu(titleBar, 0);
MenuItem first = titleBar.getButton(0);
uut.addToMenu(titleBar, 0);
MenuItem second = titleBar.getButton(0);
assertThat(first).isEqualTo(second);
uut.addToMenu(titleBar, 1);
MenuItem third = titleBar.getButton(0);
assertThat(third).isNotEqualTo(second);
}
private ButtonOptions createComponentButton() {
ButtonOptions componentButton = new ButtonOptions();
componentButton.id = "customBtn";
componentButton.component.name = new Text("com.rnn.customBtn");
componentButton.component.componentId = new Text("component4");
return componentButton;
}
}