Skip to content

Commit

Permalink
Fix oppia#3419: Separate ViewEventLogsActivityTest into activity and …
Browse files Browse the repository at this point in the history
…fragment test files (oppia#3468)

* Created ViewEventLogsFragmentTest

* Removed tests from ViewEventLogsActivityTest

* Removed ViewEventLogsFragment from test_file_exemptions

* Introduced Test Activity and added new tests

* Nit fix

* Nit fix

* Nit fixes

* Added test activities to exemption

* Added missing TODOs

* Nit fix
  • Loading branch information
yashraj-01 committed Aug 5, 2021
1 parent 1499137 commit 3f98e53
Show file tree
Hide file tree
Showing 8 changed files with 703 additions and 480 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@
android:name=".app.devoptions.vieweventlogs.ViewEventLogsActivity"
android:label="@string/view_event_logs_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.devoptions.vieweventlogs.testing.ViewEventLogsTestActivity"
android:theme="@style/OppiaThemeWithoutActionBar" />

<provider
android:name="androidx.work.impl.WorkManagerInitializer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.oppia.android.app.devoptions.marktopicscompleted.MarkTopicsCompletedA
import org.oppia.android.app.devoptions.marktopicscompleted.testing.MarkTopicsCompletedTestActivity
import org.oppia.android.app.devoptions.testing.DeveloperOptionsTestActivity
import org.oppia.android.app.devoptions.vieweventlogs.ViewEventLogsActivity
import org.oppia.android.app.devoptions.vieweventlogs.testing.ViewEventLogsTestActivity
import org.oppia.android.app.fragment.FragmentComponent
import org.oppia.android.app.help.HelpActivity
import org.oppia.android.app.help.faq.FAQListActivity
Expand Down Expand Up @@ -137,5 +138,6 @@ interface ActivityComponent {
fun inject(topicTestActivity: TopicTestActivity)
fun inject(topicTestActivityForStory: TopicTestActivityForStory)
fun inject(viewEventLogsActivity: ViewEventLogsActivity)
fun inject(viewEventLogsTestActivity: ViewEventLogsTestActivity)
fun inject(walkthroughActivity: WalkthroughActivity)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.oppia.android.app.devoptions.vieweventlogs.testing

import android.content.Context
import android.content.Intent
import android.os.Bundle
import org.oppia.android.R
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.devoptions.vieweventlogs.ViewEventLogsFragment

/** Activity for testing [ViewEventLogsFragment]. */
class ViewEventLogsTestActivity : InjectableAppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityComponent.inject(this)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24dp)
setContentView(R.layout.view_event_logs_activity)
if (getViewEventLogsFragment() == null) {
val viewEventLogsFragment = ViewEventLogsFragment.newInstance()
supportFragmentManager.beginTransaction().add(
R.id.view_event_logs_container,
viewEventLogsFragment
).commitNow()
}
}

private fun getViewEventLogsFragment(): ViewEventLogsFragment? {
return supportFragmentManager
.findFragmentById(R.id.view_event_logs_container) as ViewEventLogsFragment?
}

companion object {
/** Returns [Intent] for [ViewEventLogsTestActivity]. */
fun createViewEventLogsTestIntent(context: Context): Intent {
return Intent(context, ViewEventLogsTestActivity::class.java)
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/view_event_logs_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/view_event_logs_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
Expand Down
Loading

0 comments on commit 3f98e53

Please sign in to comment.