dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.62k stars 347 forks source link

view.type(str) too slow #72

Open gdobra opened 10 years ago

gdobra commented 10 years ago

view.type() is too slow just because it types every single character using a different 'adb shell input text' on each character contained in str. And that's done this way because adb input text won't accept space. So, instead of calling adb for each and every character, you could replace " " with "%s" and do the input in one go.

instead of: for c in str: device.type(c)

we could write: str = str.replace(" ", "%s") device.type(str)

dtmilano commented 10 years ago

Good point

gdobra commented 10 years ago

Of course, it's worth escaping the %s whenever that's exactly what the user wants to type in, in order not to be replaced by a space in the input text. So a review of adb's escape sequences would help do the job correctly.

dtmilano commented 10 years ago

Sorry, I didn't quite understand you last comment. Do you have some examples?

On Wed, Nov 27, 2013 at 5:21 AM, gdobra notifications@github.com wrote:

Of course, it's worth escaping the %s whenever that's exactly what the user wants to type in, in order not to be replaced by a space in the input text. So a review of adb's escape sequences would help do the job correctly.

— Reply to this email directly or view it on GitHubhttps://github.com/dtmilano/AndroidViewClient/issues/72#issuecomment-29373624 .

Have you read my blog ? http://dtmilano.blogspot.com android junit tests ui linux cult thin clients

gdobra commented 10 years ago

well, if I really want to input "%s" that should be escaped as "\%s" or something. So, if my text is "this is %s", that should be modified as "this%sis%s\%s"