Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gz/convert to kotlin #100

Merged
merged 16 commits into from
Sep 3, 2018
Merged

Gz/convert to kotlin #100

merged 16 commits into from
Sep 3, 2018

Conversation

gigiyy
Copy link
Contributor

@gigiyy gigiyy commented Aug 14, 2018

example App conversion to kotlin

  • convert the source code to kotlin using IDE own tool
  • bounced the SDK version, gradle version, android plugin version and espresso test versions.
  • using class name to look for the text fields with UiSelector in MainActivity test.

@gigiyy gigiyy force-pushed the gz/convert_to_kotlin branch from 70fc2c4 to 85bd7eb Compare August 16, 2018 14:21
@guillaumedebavelaere
Copy link
Contributor

  • Can we keep the java exampleApp and move the Kotlin code in a separate example app target?
  • Are the tests ok?
  • Did you test with old versions of Android in the emulator?

@oliver-was-here
Copy link

@gigiyy I'll take a look at this tomorrow, my brain has had too much PR for one day 😬

@oliver-was-here
Copy link

seems odd to me that all the source is nested under main/java, is it possible to move these .kt files to main/kotlin?

Copy link
Contributor

@guillaumedebavelaere guillaumedebavelaere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes of the android target/compile versions, have you tested with different versions in the emulator? The ideal would be to test with the min and max version.
The tests are not passing for me (version 23 in the emulator) for the java version, and for the Kotlin version I am not able to launch anything, it says to select a SDK version:
capture d ecran 2018-08-30 a 11 30 51

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_linked_broker_accounts)
val textView = linked_broker_accounts_textview //this.findViewById(R.id.linked_broker_accounts_textview) as TextView?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted

/**
* [Testing Fundamentals](http://d.android.com/tools/testing/testing_android.html)
*/
class ApplicationTest : ApplicationTestCase<Application>(Application::class.java)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, can we delete this, as it does nothing special?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted. it seems the left over of the skeleton when application is created.

/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
class ExampleUnitTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this, as it does nothing special?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted. this folder was supposed to contain those tests that don't need to use espresso test framework.

implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.anko:anko:$anko_version"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this library for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/Kotlin/anko, I'm planning the use this library when further improvement to the app is done. it can be safely removed though if not needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, if currently there are nothing using it, can you remove it?

"orderId='" + orderId + '\'' +
", orderDetails=" + orderDetails +
"orderId='" + orderId + "'" +
", ackWarningsList=[]" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are empty arrays?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regenerate using the IDE instead.

@@ -34,6 +34,42 @@
TradeItOrderDetailsParcelable() {
}

@Override
public String toString() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a real benefit in term of performance, writing a custom toString() with StringBuilder than generating the method by IntelliJ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just didn't realize it can be generated. 😱

@@ -68,8 +68,8 @@
DELETE_ALL_LINKED_BROKERS("Delete all linked brokers"),
AUTHENTICATE_FIRST_LINKED_BROKER("Authenticate first linked broker"),
AUTHENTICATE_ALL_LINKED_BROKERS("Authenticate all linked brokers"),
AUTHENTICATE_WITH_SECURITY_QUESTION_SIMPLE("Simple security question"),
AUTHENTICATE_WITH_SECURITY_QUESTION_OPTIONS("Security question with options"),
// AUTHENTICATE_WITH_SECURITY_QUESTION_SIMPLE("Simple security question"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

originally it's not implemented, not used at all. in fact, to test security questions, we just need to use same testOAuthFlow and use dummySecurity and dummyOption instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, can we remove them if we are not using instead of commenting out?

@gigiyy
Copy link
Contributor Author

gigiyy commented Aug 30, 2018

HI @guillaumedebavelaere, you will need to install chrome browser in your emulator( I tested in api level22, android 5.1) and it works ok. you can download the apk from apkmirror.com inside the emulator itself. the reason is that, current test only works with chrome custom tab, and not working with webview for oAuth pages (will need to use espresso-web instead)

@guillaumedebavelaere
Copy link
Contributor

guillaumedebavelaere commented Aug 30, 2018

I installed chrome, but the tests are not passing (API 19). It is blocked when entering the credentials in the oAuth flow.

android.support.test.uiautomator.UiObjectNotFoundException: UiSelector[RESOURCE_ID=loginUser]

@gigiyy
Copy link
Contributor Author

gigiyy commented Aug 30, 2018

can you try run uiautomatorviewer when the oAuth page is shown and check whether it's a webview or a chrome tab? you should be able to inspect the text field if it's a custom tab.

@gigiyy gigiyy force-pushed the gz/convert_to_kotlin branch from 7b268ba to d17f84f Compare August 30, 2018 15:40
@guillaumedebavelaere
Copy link
Contributor

working now 👍

@guillaumedebavelaere
Copy link
Contributor

Let's wait to review and merge this one before: #102

@guillaumedebavelaere guillaumedebavelaere merged commit ef6b642 into develop Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants