/*
 * Copyright 2016 Andrey Tolpeev
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.vase4kin.teamcityapp.about;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import com.github.vase4kin.teamcityapp.R;
import com.github.vase4kin.teamcityapp.TeamCityApplication;
import com.github.vase4kin.teamcityapp.dagger.components.AppComponent;
import com.github.vase4kin.teamcityapp.dagger.components.RestApiComponent;
import com.github.vase4kin.teamcityapp.dagger.modules.AppModule;
import com.github.vase4kin.teamcityapp.dagger.modules.RestApiModule;
import com.github.vase4kin.teamcityapp.helper.CustomActivityTestRule;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import it.cosenonjaviste.daggermock.DaggerMockRule;

import static com.github.vase4kin.teamcityapp.helper.TestUtils.matchToolbarTitle;

/**
 * Tests for {@link AboutLibrariesActivity}
 */
@RunWith(AndroidJUnit4.class)
public class AboutLibrariesActivityTest {

    private static final String URL = "http://teamcity.server.com";

    @Rule
    public DaggerMockRule<RestApiComponent> mDaggerRule = new DaggerMockRule<>(RestApiComponent.class, new RestApiModule(URL))
            .addComponentDependency(AppComponent.class, new AppModule((TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext()))
            .set(restApiComponent -> {
                TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
                app.setRestApiInjector(restApiComponent);
            });

    @Rule
    public CustomActivityTestRule<AboutLibrariesActivity> mActivityTestRule = new CustomActivityTestRule<>(AboutLibrariesActivity.class);

    @Test
    public void testAboutActivity() {
        mActivityTestRule.launchActivity(null);
        String toolbarTitle = mActivityTestRule.getActivity().getString(R.string.about_app_text_libraries);
        matchToolbarTitle(toolbarTitle);
    }
}
@@ -1062,32 +1062,93 @@
 ules.AppModule;%0A
+import com.github.vase4kin.teamcityapp.dagger.modules.Mocks;%0A
 import com.githu
@@ -1267,24 +1267,49 @@
 yTestRule;%0A%0A
+import org.junit.Before;%0A
 import org.j
@@ -2437,24 +2437,388 @@
 ty.class);%0A%0A
+    @Before%0A    public void setUp() %7B%0A        TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();%0A        app.getRestApiInjector().sharedUserStorage().clearAll();%0A        app.getRestApiInjector().sharedUserStorage().saveGuestUserAccountAndSetItAsActive(Mocks.URL, false);%0A    %7D%0A%0A
     @Test%0A  

Fix UI tests