Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ dependencies {
compile libraries.supportDesign
compile libraries.supportRecyclerView
compile libraries.supportCardView
compile libraries.supportConstraintLayout

compile libraries.flexbox

compile libraries.butterKnife
apt libraries.butterKnifeCompiler
Expand Down
41 changes: 41 additions & 0 deletions app/src/main/res/layout/constraint_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ContentDescription">

<ImageView
android:id="@+id/item_00"
style="@style/Item.00"/>

<ImageView
android:id="@+id/item_01"
style="@style/Item.01"
app:layout_constraintLeft_toRightOf="@id/item_00"/>

<ImageView
android:id="@+id/item_02"
style="@style/Item.02"
app:layout_constraintLeft_toRightOf="@id/item_01"/>

<ImageView
android:id="@+id/item_10"
style="@style/Item.10"
app:layout_constraintTop_toBottomOf="@id/item_00"/>

<ImageView
android:id="@+id/item_11"
style="@style/Item.11"
app:layout_constraintLeft_toRightOf="@id/item_10"
app:layout_constraintTop_toBottomOf="@id/item_01"/>

<ImageView
android:id="@+id/item_12"
style="@style/Item.12"
app:layout_constraintLeft_toRightOf="@id/item_11"
app:layout_constraintTop_toBottomOf="@id/item_02"/>

</android.support.constraint.ConstraintLayout>
25 changes: 25 additions & 0 deletions app/src/main/res/layout/flexbox_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.flexbox.FlexboxLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:flexWrap="wrap"
tools:ignore="ContentDescription">

<ImageView style="@style/Item.00"/>

<ImageView style="@style/Item.01"/>

<ImageView style="@style/Item.02"/>

<ImageView
style="@style/Item.10"
app:layout_wrapBefore="true"/>

<ImageView style="@style/Item.11"/>

<ImageView style="@style/Item.12"/>

</com.google.android.flexbox.FlexboxLayout>
37 changes: 29 additions & 8 deletions app/src/main/res/layout/fragment_content.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
>
android:layout_height="match_parent">

<include layout="@layout/frame_layout" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">

<include layout="@layout/linear_layout" />
<!-- Measure | Layout | Draw [ms] -->

</LinearLayout>
<!-- 0.035 | 0.017 | 0.900 -->
<include layout="@layout/frame_layout"/>

<!-- 0.045 | 0.022 | 0.804 -->
<include layout="@layout/linear_layout"/>

<!-- 0.060 | 0.010 | 0.739 -->
<include layout="@layout/relative_layout"/>

<!-- 0.077 | 0.026 | 0.716 -->
<include layout="@layout/table_layout"/>

<!-- 0.552 | 0.018 | 0.816 -->
<include layout="@layout/constraint_layout"/>

<!-- 0.121 | 0.023 | 0.723 -->
<include layout="@layout/flexbox_layout"/>

</LinearLayout>

</ScrollView>
40 changes: 40 additions & 0 deletions app/src/main/res/layout/relative_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ContentDescription,RtlHardcoded">

<ImageView
android:id="@+id/item_00"
style="@style/Item.00"/>

<ImageView
android:id="@+id/item_01"
style="@style/Item.01"
android:layout_toRightOf="@id/item_00"/>

<ImageView
android:id="@+id/item_02"
style="@style/Item.02"
android:layout_toRightOf="@id/item_01"/>

<ImageView
android:id="@+id/item_10"
style="@style/Item.10"
android:layout_below="@id/item_00"/>

<ImageView
android:id="@+id/item_11"
style="@style/Item.11"
android:layout_below="@id/item_01"
android:layout_toRightOf="@id/item_10"/>

<ImageView
android:id="@+id/item_12"
style="@style/Item.12"
android:layout_below="@id/item_02"
android:layout_toRightOf="@id/item_11"/>

</RelativeLayout>
33 changes: 33 additions & 0 deletions app/src/main/res/layout/table_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ContentDescription">

<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView style="@style/Item.00"/>

<ImageView style="@style/Item.01"/>

<ImageView style="@style/Item.02"/>

</TableRow>

<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView style="@style/Item.10"/>

<ImageView style="@style/Item.11"/>

<ImageView style="@style/Item.12"/>

</TableRow>

</TableLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources>
<string name="app_name">Yamblz</string>
<string name="app_name">ViewGroups HW</string>
<string name="content">Hello</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,27 @@
import org.junit.Before;
import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.Date;

import hu.supercluster.paperwork.Paperwork;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

public class DeveloperSettingsModelImplTest {
private DeveloperSettingsModelImpl developerSettingsModel;
private DeveloperSettings developerSettings;
private Paperwork paperwork;

@Before
public void beforeEachTest() {
developerSettings = mock(DeveloperSettings.class);
paperwork = mock(Paperwork.class);

developerSettingsModel = new DeveloperSettingsModelImpl(
mock(App.class),
developerSettings,
mock(LeakCanaryProxy.class),
paperwork
mock(LeakCanaryProxy.class)
);
}

@Test
public void testGetGitSha() {
when(paperwork.get("gitSha")).thenReturn("abc123");

assertThat(developerSettingsModel.getGitSha()).isEqualTo("abc123");
verify(paperwork).get("gitSha");
verifyNoMoreInteractions(paperwork);
}

@Test
public void getGitSha_shouldReturnSameResultForSeveralCalls() {
when(paperwork.get("gitSha")).thenReturn("abc123");

String sha1 = developerSettingsModel.getGitSha();
String sha2 = developerSettingsModel.getGitSha();
String sha3 = developerSettingsModel.getGitSha();

assertThat(sha1).isEqualTo(sha2).isEqualTo(sha3).isEqualTo("abc123");
}

@Test
public void testGetBuildDate() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = dateFormat.format(new Date());
when(paperwork.get("buildDate")).thenReturn(date);

assertThat(developerSettingsModel.getBuildDate()).isEqualTo(date);
verify(paperwork).get("buildDate");
verifyNoMoreInteractions(paperwork);
}

@Test
public void getBuildDate_shouldReturnSameResultForSeveralCalls() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = dateFormat.format(new Date());
when(paperwork.get("buildDate")).thenReturn(date);

String buildDate1 = developerSettingsModel.getBuildDate();
String buildDate2 = developerSettingsModel.getBuildDate();
String buildDate3 = developerSettingsModel.getBuildDate();

assertThat(buildDate1).isEqualTo(buildDate2).isEqualTo(buildDate3).isEqualTo(date);
}

@Test
public void getBuildVersionCode_shouldNotBeNull() {
assertThat(developerSettingsModel.getBuildVersionCode()).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@ public void beforeEachTest() {
developerSettingsView = mock(DeveloperSettingsView.class);
}

@Test
public void bindView_shouldSendGitShaToTheView() {
when(developerSettingsModel.getGitSha()).thenReturn("test git sha");

developerSettingsPresenter.bindView(developerSettingsView);
verify(developerSettingsView).changeGitSha("test git sha");
}

@Test
public void bindView_shouldSendBuildDateToTheView() {
when(developerSettingsModel.getBuildDate()).thenReturn("test build date");

developerSettingsPresenter.bindView(developerSettingsView);
verify(developerSettingsView).changeBuildDate("test build date");
}

@Test
public void bindView_shouldSendBuildVersionCodeToTheView() {
when(developerSettingsModel.getBuildVersionCode()).thenReturn("test build version code");
Expand Down
7 changes: 6 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ext.versions = [
compileSdk : 23,
buildTools : '23.0.3',

androidGradlePlugin : '2.2.0-alpha4',
androidGradlePlugin : '2.1.2',
aptGradlePlugin : '1.8',
retrolambdaGradlePlugin : '3.2.5',
lombokGradlePlugin : '0.2.3.a2',
Expand All @@ -23,6 +23,8 @@ ext.versions = [
supportLibs : '23.4.0',
butterKnife : '8.0.1',
timber : '4.1.2',
supportConstraintLayout : '1.0.0-alpha1',
flexbox : '0.2.2',

espresso : '2.2.1',
stetho : '1.3.1',
Expand Down Expand Up @@ -63,6 +65,9 @@ ext.libraries = [
supportRecyclerView : "com.android.support:recyclerview-v7:$versions.supportLibs",
supportCardView : "com.android.support:cardview-v7:$versions.supportLibs",

supportConstraintLayout : "com.android.support.constraint:constraint-layout:$versions.supportConstraintLayout",
flexbox : "com.google.android:flexbox:$versions.flexbox",

butterKnife : "com.jakewharton:butterknife:$versions.butterKnife",
butterKnifeCompiler : "com.jakewharton:butterknife-compiler:$versions.butterKnife",
timber : "com.jakewharton.timber:timber:$versions.timber",
Expand Down