Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 88cdc6e

Browse files
authored
Merge pull request #128 from vase4kin/dev
Release 1.3.0
2 parents d1b0cd7 + 7376112 commit 88cdc6e

File tree

157 files changed

+3824
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+3824
-272
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
22
[![Circle CI](https://circleci.com/gh/vase4kin/TeamCityApp/tree/master.svg?style=shield)](https://circleci.com/gh/vase4kin/TeamCityApp/tree/master)
33
[![codecov](https://codecov.io/gh/vase4kin/TeamCityApp/branch/master/graph/badge.svg)](https://codecov.io/gh/vase4kin/TeamCityApp)
4-
[![Release](https://img.shields.io/badge/release-1.2.9.2-blue.svg)](https://github.com/vase4kin/TeamCityApp/releases/latest)
4+
[![Release](https://img.shields.io/badge/release-1.3.0-blue.svg)](https://github.com/vase4kin/TeamCityApp/releases/latest)
55

66
```
77

app/src/androidTest/java/com/github/vase4kin/teamcityapp/artifact/view/ArtifactListFragmentTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,7 @@ public void testUserSeeSnackBarWithErrorMessageIfArtifactWasNotDownloaded() thro
477477
.perform(click());
478478

479479
// Clicking on artifact to download
480-
onView(withRecyclerView(R.id.artifact_recycler_view)
481-
.atPositionOnView(1, R.id.itemTitle))
482-
.perform(click());
480+
onView(withText("AndroidManifest.xml")).perform(click());
483481

484482
ConditionWatcher.waitForCondition(new Instruction() {
485483
@Override

app/src/androidTest/java/com/github/vase4kin/teamcityapp/buildlist/view/BuildListActivityTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import static android.support.test.espresso.Espresso.onView;
6363
import static android.support.test.espresso.action.ViewActions.click;
6464
import static android.support.test.espresso.assertion.ViewAssertions.matches;
65+
import static android.support.test.espresso.intent.Intents.assertNoUnverifiedIntents;
6566
import static android.support.test.espresso.intent.Intents.intended;
6667
import static android.support.test.espresso.intent.Intents.intending;
6768
import static android.support.test.espresso.intent.matcher.BundleMatchers.hasEntry;
@@ -396,4 +397,27 @@ public void testUserCanSeeSnackBarIfBuildFiltersHaveBeenApplied() throws Excepti
396397
// Check data was loaded with new filter
397398
verify(mTeamCityService).listBuilds(eq("build_type_id"), eq("canceled:true,branch:name:branch,personal:true,pinned:true,count:10"));
398399
}
400+
401+
@Test
402+
public void testUserCannotClickOnSection() throws Exception {
403+
mActivityRule.launchActivity(null);
404+
405+
// Open build type
406+
onView(withText("build type"))
407+
.perform(click());
408+
409+
intended(allOf(
410+
hasComponent(BuildListActivity.class.getName()),
411+
hasExtras(allOf(
412+
hasEntry(equalTo(BundleExtractorValues.BUILD_LIST_FILTER), equalTo(null)),
413+
hasEntry(equalTo(BundleExtractorValues.ID), equalTo("build_type_id")),
414+
hasEntry(equalTo(BundleExtractorValues.NAME), equalTo("build type"))))));
415+
416+
// Clicking on header
417+
onView(withRecyclerView(R.id.build_recycler_view).atPositionOnView(0, R.id.section_text))
418+
.check(matches(withText("22 June")))
419+
.perform(click());
420+
421+
assertNoUnverifiedIntents();
422+
}
399423
}

app/src/androidTest/java/com/github/vase4kin/teamcityapp/drawer/DrawerTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,26 @@ public void testUserCanNavigateToAccounts() throws Exception {
230230
matchToolbarTitle("Manage Accounts");
231231
}
232232

233+
@Test
234+
public void testUserCanNavigateToFavorites() throws Exception {
235+
// Opening drawer
236+
clickOnBurgerButton();
237+
238+
// Check fav is opened
239+
onView(allOf(withId(R.id.material_drawer_name), withText(R.string.favorites_drawer_item), isDisplayed()))
240+
.perform(click());
241+
242+
// Checking toolbar title
243+
matchToolbarTitle("Favorites (0)");
244+
245+
// Opening drawer
246+
clickOnBurgerButton();
247+
248+
// Check fav is selected
249+
onView(allOf(withId(R.id.material_drawer_name), withText(R.string.favorites_drawer_item), isDisplayed()))
250+
.check(matches(isSelected()));
251+
}
252+
233253
/**
234254
* Open drawer by clicking on burger button
235255
*/
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
/*
2+
* Copyright 2016 Andrey Tolpeev
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.github.vase4kin.teamcityapp.favorites.view;
18+
19+
import android.content.Intent;
20+
import android.support.test.InstrumentationRegistry;
21+
import android.support.test.runner.AndroidJUnit4;
22+
23+
import com.github.vase4kin.teamcityapp.R;
24+
import com.github.vase4kin.teamcityapp.TeamCityApplication;
25+
import com.github.vase4kin.teamcityapp.api.TeamCityService;
26+
import com.github.vase4kin.teamcityapp.dagger.components.AppComponent;
27+
import com.github.vase4kin.teamcityapp.dagger.components.RestApiComponent;
28+
import com.github.vase4kin.teamcityapp.dagger.modules.AppModule;
29+
import com.github.vase4kin.teamcityapp.dagger.modules.FakeTeamCityServiceImpl;
30+
import com.github.vase4kin.teamcityapp.dagger.modules.Mocks;
31+
import com.github.vase4kin.teamcityapp.dagger.modules.RestApiModule;
32+
import com.github.vase4kin.teamcityapp.helper.CustomIntentsTestRule;
33+
import com.github.vase4kin.teamcityapp.helper.TestUtils;
34+
import com.github.vase4kin.teamcityapp.navigation.api.BuildType;
35+
import com.github.vase4kin.teamcityapp.root.view.RootProjectsActivity;
36+
import com.github.vase4kin.teamcityapp.storage.SharedUserStorage;
37+
38+
import org.junit.Before;
39+
import org.junit.BeforeClass;
40+
import org.junit.Rule;
41+
import org.junit.Test;
42+
import org.junit.runner.RunWith;
43+
import org.mockito.Spy;
44+
45+
import it.cosenonjaviste.daggermock.DaggerMockRule;
46+
import rx.Observable;
47+
48+
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
49+
import static android.support.test.espresso.Espresso.onView;
50+
import static android.support.test.espresso.action.ViewActions.click;
51+
import static android.support.test.espresso.assertion.ViewAssertions.matches;
52+
import static android.support.test.espresso.intent.Intents.intended;
53+
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
54+
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasFlags;
55+
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
56+
import static android.support.test.espresso.matcher.ViewMatchers.withId;
57+
import static android.support.test.espresso.matcher.ViewMatchers.withText;
58+
import static com.github.vase4kin.teamcityapp.helper.RecyclerViewMatcher.withRecyclerView;
59+
import static com.github.vase4kin.teamcityapp.helper.TestUtils.hasItemsCount;
60+
import static com.github.vase4kin.teamcityapp.helper.TestUtils.matchToolbarTitle;
61+
import static org.hamcrest.core.AllOf.allOf;
62+
import static org.mockito.Matchers.anyString;
63+
import static org.mockito.Mockito.when;
64+
65+
@RunWith(AndroidJUnit4.class)
66+
public class FavoritesActivityTest {
67+
68+
@Rule
69+
public DaggerMockRule<AppComponent> daggerRule = new DaggerMockRule<>(AppComponent.class, new AppModule((TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext()))
70+
.set(new DaggerMockRule.ComponentSetter<AppComponent>() {
71+
@Override
72+
public void setComponent(AppComponent appComponent) {
73+
TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
74+
app.setAppInjector(appComponent);
75+
}
76+
});
77+
78+
@Rule
79+
public DaggerMockRule<RestApiComponent> restComponentDaggerRule = new DaggerMockRule<>(RestApiComponent.class, new RestApiModule(Mocks.URL))
80+
.addComponentDependency(AppComponent.class, new AppModule((TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext()))
81+
.set(new DaggerMockRule.ComponentSetter<RestApiComponent>() {
82+
@Override
83+
public void setComponent(RestApiComponent restApiComponent) {
84+
TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
85+
app.setRestApiInjector(restApiComponent);
86+
}
87+
});
88+
89+
@Rule
90+
public CustomIntentsTestRule<FavoritesActivity> activityRule = new CustomIntentsTestRule<>(FavoritesActivity.class);
91+
92+
@Spy
93+
private TeamCityService teamCityService = new FakeTeamCityServiceImpl();
94+
95+
@BeforeClass
96+
public static void disableOnboarding() {
97+
TestUtils.disableOnboarding();
98+
}
99+
100+
@Before
101+
public void setUp() {
102+
SharedUserStorage storage = getStorage();
103+
storage.clearAll();
104+
storage.saveGuestUserAccountAndSetItAsActive(Mocks.URL, false);
105+
}
106+
107+
@Test
108+
public void testUserCanSeeFavoritesListIfSmthBadHappensInFavoritesLoading() {
109+
// prepare mocks
110+
when(teamCityService.buildType(anyString())).thenReturn(Observable.<BuildType>error(new RuntimeException("smth bad happend!")));
111+
getStorage().addBuildTypeToFavorites("id");
112+
getStorage().addBuildTypeToFavorites("id2");
113+
getStorage().addBuildTypeToFavorites("id3");
114+
115+
// launch activity
116+
activityRule.launchActivity(null);
117+
118+
// Check empty list
119+
onView(withId(android.R.id.empty)).check(matches(isDisplayed())).check(matches(withText(R.string.empty_list_message_favorites)));
120+
}
121+
122+
@Test
123+
public void testUserCanSeeLoadEmptyListMessageIfFavoritesIsEmpty() {
124+
// launch activity
125+
activityRule.launchActivity(null);
126+
127+
// Checking toolbar title
128+
matchToolbarTitle("Favorites (0)");
129+
130+
// Check the list is empty
131+
onView(withId(android.R.id.empty)).check(matches(isDisplayed())).check(matches(withText(R.string.empty_list_message_favorites)));
132+
}
133+
134+
@Test
135+
public void testUserCanClickOnFabAndSeeProjects() {
136+
// launch activity
137+
activityRule.launchActivity(null);
138+
139+
// click on fab
140+
onView(withId(R.id.floating_action_button)).perform(click());
141+
142+
// check snack bar text
143+
onView(withText(R.string.text_info_add)).check(matches(isDisplayed()));
144+
145+
// click on snack bar action
146+
onView(withText(R.string.text_info_add_action)).perform(click());
147+
148+
// check activity is opened
149+
intended(allOf(
150+
hasComponent(RootProjectsActivity.class.getName()),
151+
hasFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
152+
| FLAG_ACTIVITY_SINGLE_TOP)));
153+
154+
}
155+
156+
@Test
157+
public void testUserCanAddBuildTypeToFavorites() {
158+
//prepare mocks
159+
when(teamCityService.buildType(Mocks.buildTypeMock().getId())).thenReturn(Observable.just(Mocks.buildTypeMock()));
160+
161+
// launch activity
162+
activityRule.launchActivity(null);
163+
164+
// click on fab
165+
onView(withId(R.id.floating_action_button)).perform(click());
166+
167+
// click on snack bar action
168+
onView(withText(R.string.text_info_add_action)).perform(click());
169+
170+
// Open build type
171+
onView(withText("build type"))
172+
.perform(click());
173+
174+
// Click on add to favorites
175+
onView(withId(R.id.add_to_favorites)).perform(click());
176+
177+
// check snack bar text
178+
onView(withText(R.string.text_add_to_favorites)).check(matches(isDisplayed()));
179+
180+
// click on snack bar action
181+
onView(withText(R.string.text_view_favorites)).perform(click());
182+
183+
// Checking toolbar title
184+
matchToolbarTitle("Favorites (1)");
185+
186+
// List has item with header
187+
onView(withId(R.id.favorites_recycler_view)).check(hasItemsCount(2));
188+
// Checking header 1
189+
onView(withRecyclerView(R.id.favorites_recycler_view).atPositionOnView(0, R.id.section_text))
190+
.check(matches(withText("Secret project")));
191+
// Checking adapter item 1
192+
onView(withRecyclerView(R.id.favorites_recycler_view).atPositionOnView(1, R.id.itemTitle))
193+
.check(matches(withText("build type")));
194+
}
195+
196+
private SharedUserStorage getStorage() {
197+
TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
198+
return app.getAppInjector().sharedUserStorage();
199+
}
200+
}

app/src/androidTest/java/com/github/vase4kin/teamcityapp/helper/TestUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,7 @@ public static void disableOnboarding() {
106106
onboardingManager.saveRemoveBuildFromQueuePromptShown();
107107
onboardingManager.saveStopBuildPromptShown();
108108
onboardingManager.saveRestartBuildPromptShown();
109+
onboardingManager.saveAddFavPromptShown();
110+
onboardingManager.saveFavPromptShown();
109111
}
110112
}

0 commit comments

Comments
 (0)