Skip to content

Commit

Permalink
Formatting nits
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAlcerreca committed Feb 29, 2016
1 parent 8e65642 commit ec1f6da
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ protected void onCreate(Bundle savedInstanceState) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);

AddEditTaskFragment addEditTaskFragment =
(AddEditTaskFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
AddEditTaskFragment addEditTaskFragment = (AddEditTaskFragment) getSupportFragmentManager()
.findFragmentById(R.id.contentFrame);

String taskId = null;
if (addEditTaskFragment == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ public void onClick(View v) {
swipeRefreshLayout.setColorSchemeColors(
ContextCompat.getColor(getActivity(), R.color.colorPrimary),
ContextCompat.getColor(getActivity(), R.color.colorAccent),
ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark)
);
ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark));
// Set the scrolling view in the custom SwipeRefreshLayout.
swipeRefreshLayout.setScrollUpChild(listView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,5 +265,4 @@ public void popupItemSelected(int itemId) {
public TasksFilterType getFiltering() {
return mCurrentFiltering;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public void setupStatisticsPresenter() {
MockitoAnnotations.initMocks(this);

// Get a reference to the class under test
mStatisticsPresenter = new StatisticsPresenter(mStatisticsView, mTasksLoader, mLoaderManager);
mStatisticsPresenter = new StatisticsPresenter(
mStatisticsView, mTasksLoader, mLoaderManager);

// We initialise the tasks to 3, with one active and two completed
TASKS = Lists.newArrayList(new Task("Title1", "Description1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public void getActiveTaskFromRepositoryAndLoadIntoView() {

// Get a reference to the class under test
mTaskDetailPresenter = new TaskDetailPresenter(
ACTIVE_TASK.getId(), mTasksRepository, mTaskDetailFragment, mTaskLoader, mLoaderManager);
ACTIVE_TASK.getId(), mTasksRepository, mTaskDetailFragment, mTaskLoader,
mLoaderManager);
mTaskDetailPresenter.onLoadFinished(mock(Loader.class), ACTIVE_TASK);

// Then progress indicator is hidden and title, description and completion status are shown
Expand All @@ -85,8 +86,8 @@ public void getActiveTaskFromRepositoryAndLoadIntoView() {
@Test
public void getCompletedTaskFromRepositoryAndLoadIntoView() {
// When tasks presenter is asked to open a completed task
mTaskDetailPresenter = new TaskDetailPresenter(
COMPLETED_TASK.getId(), mTasksRepository, mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter = new TaskDetailPresenter(COMPLETED_TASK.getId(), mTasksRepository,
mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter.onLoadFinished(mock(Loader.class), COMPLETED_TASK);

// Then progress indicator is hidden and title, description and completion status are shown
Expand All @@ -100,8 +101,8 @@ public void getCompletedTaskFromRepositoryAndLoadIntoView() {
@Test
public void getUnknownTaskFromRepositoryAndLoadIntoView() {
// When loading of an ACTIVE_TASK is requested with an invalid task
mTaskDetailPresenter = new TaskDetailPresenter(
INVALID_TASK_ID, mTasksRepository, mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter = new TaskDetailPresenter(INVALID_TASK_ID, mTasksRepository,
mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter.onLoadFinished(mock(Loader.class), null);

// Then progress indicator is hidden and missing ACTIVE_TASK UI is shown
Expand All @@ -111,8 +112,8 @@ public void getUnknownTaskFromRepositoryAndLoadIntoView() {
@Test
public void deleteTask() {
// When the deletion of an ACTIVE_TASK is requested
mTaskDetailPresenter = new TaskDetailPresenter(
ACTIVE_TASK.getId(), mTasksRepository, mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter = new TaskDetailPresenter(ACTIVE_TASK.getId(), mTasksRepository,
mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter.deleteTask();

// Then the repository and the view are notified
Expand All @@ -123,8 +124,8 @@ public void deleteTask() {
@Test
public void completeTask() {
// When the presenter is asked to complete the ACTIVE_TASK
mTaskDetailPresenter = new TaskDetailPresenter(
ACTIVE_TASK.getId(), mTasksRepository, mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter = new TaskDetailPresenter(ACTIVE_TASK.getId(), mTasksRepository,
mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter.completeTask();

// Then a request is sent to the repository and the UI is updated
Expand All @@ -135,8 +136,8 @@ public void completeTask() {
@Test
public void activateTask() {
// When the presenter is asked to activate the ACTIVE_TASK
mTaskDetailPresenter = new TaskDetailPresenter(
ACTIVE_TASK.getId(), mTasksRepository, mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter = new TaskDetailPresenter(ACTIVE_TASK.getId(), mTasksRepository,
mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter.activateTask();

// Then a request is sent to the repository and the UI is updated
Expand All @@ -147,8 +148,8 @@ public void activateTask() {
@Test
public void activeTaskIsShownWhenEditing() {
// When the edit of an ACTIVE_TASK is requested
mTaskDetailPresenter = new TaskDetailPresenter(
ACTIVE_TASK.getId(), mTasksRepository, mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter = new TaskDetailPresenter(ACTIVE_TASK.getId(), mTasksRepository,
mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter.editTask();

// Then the view is notified
Expand All @@ -158,8 +159,8 @@ public void activeTaskIsShownWhenEditing() {
@Test
public void invalidTaskIsNotShownWhenEditing() {
// When the edit of an invalid task id is requested
mTaskDetailPresenter = new TaskDetailPresenter(
INVALID_TASK_ID, mTasksRepository, mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter = new TaskDetailPresenter(INVALID_TASK_ID, mTasksRepository,
mTaskDetailFragment, mTaskLoader, mLoaderManager);
mTaskDetailPresenter.editTask();

// Then the edit mode is never started
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ public void setupTasksPresenter() {
MockitoAnnotations.initMocks(this);

// Get a reference to the class under test
mTasksPresenter = new TasksPresenter(mTasksLoader, mLoaderManager, mTasksRepository, mTasksView);
mTasksPresenter = new TasksPresenter(
mTasksLoader, mLoaderManager, mTasksRepository, mTasksView);

// We initialise the tasks to 3, with one active and two completed
TASKS = Lists.newArrayList(new Task("Title1", "Description1"),
new Task("Title2", "Description2", true), new Task("Title3", "Description3", true)
new Task("Title2", "Description2", true),
new Task("Title3", "Description3", true)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (statisticsFragment == null) {
statisticsFragment = StatisticsFragment.newInstance();
ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),
statisticsFragment, R.id.contentFrame
);
statisticsFragment, R.id.contentFrame);
}

new StatisticsPresenter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,4 @@ public void showLoadingStatisticsError() {
public boolean isActive() {
return isAdded();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,4 @@ public void onDataNotAvailable() {
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ protected void onCreate(Bundle savedInstanceState) {
}

// Create the presenter
new TaskDetailPresenter(taskId, Injection.provideTasksRepository(getApplicationContext()), taskDetailFragment);
new TaskDetailPresenter(
taskId,
Injection.provideTasksRepository(getApplicationContext()),
taskDetailFragment);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,4 @@ private void showTask(Task task) {
}
mTaskDetailView.showCompletionStatus(task.isCompleted());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public void setup() {
@Test
public void getActiveTaskFromRepositoryAndLoadIntoView() {
// When tasks presenter is asked to open a task
mTaskDetailPresenter = new TaskDetailPresenter(ACTIVE_TASK.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter = new TaskDetailPresenter(
ACTIVE_TASK.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter.start();

// Then task is loaded from model, callback is captured and progress indicator is shown
Expand All @@ -95,11 +96,13 @@ public void getActiveTaskFromRepositoryAndLoadIntoView() {

@Test
public void getCompletedTaskFromRepositoryAndLoadIntoView() {
mTaskDetailPresenter = new TaskDetailPresenter(COMPLETED_TASK.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter = new TaskDetailPresenter(
COMPLETED_TASK.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter.start();

// Then task is loaded from model, callback is captured and progress indicator is shown
verify(mTasksRepository).getTask(eq(COMPLETED_TASK.getId()), mGetTaskCallbackCaptor.capture());
verify(mTasksRepository).getTask(
eq(COMPLETED_TASK.getId()), mGetTaskCallbackCaptor.capture());
verify(mTaskDetailView).setLoadingIndicator(true);

// When task is finally loaded
Expand All @@ -116,7 +119,8 @@ public void getCompletedTaskFromRepositoryAndLoadIntoView() {
@Test
public void getUnknownTaskFromRepositoryAndLoadIntoView() {
// When loading of a task is requested with an invalid task ID.
mTaskDetailPresenter = new TaskDetailPresenter(INVALID_TASK_ID, mTasksRepository, mTaskDetailView);
mTaskDetailPresenter = new TaskDetailPresenter(
INVALID_TASK_ID, mTasksRepository, mTaskDetailView);
mTaskDetailPresenter.start();
verify(mTaskDetailView).showMissingTask();
}
Expand All @@ -127,7 +131,8 @@ public void deleteTask() {
Task task = new Task(TITLE_TEST, DESCRIPTION_TEST);

// When the deletion of a task is requested
mTaskDetailPresenter = new TaskDetailPresenter(task.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter = new TaskDetailPresenter(
task.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter.deleteTask();

// Then the repository and the view are notified
Expand All @@ -139,7 +144,8 @@ public void deleteTask() {
public void completeTask() {
// Given an initialized presenter with an active task
Task task = new Task(TITLE_TEST, DESCRIPTION_TEST);
mTaskDetailPresenter = new TaskDetailPresenter(task.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter = new TaskDetailPresenter(
task.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter.start();

// When the presenter is asked to complete the task
Expand All @@ -154,7 +160,8 @@ public void completeTask() {
public void activateTask() {
// Given an initialized presenter with a completed task
Task task = new Task(TITLE_TEST, DESCRIPTION_TEST, true);
mTaskDetailPresenter = new TaskDetailPresenter(task.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter = new TaskDetailPresenter(
task.getId(), mTasksRepository, mTaskDetailView);
mTaskDetailPresenter.start();

// When the presenter is asked to activate the task
Expand Down

0 comments on commit ec1f6da

Please sign in to comment.