Testing with Activity Monitor

by Brian Phagan » Tue, 12 Apr 2011 07:23:45 GMT


Sponsored Links
 I am trying to write unit tests for my application.  I have a button
that initiates a call, and to test it I am trying to use an Activity
Monitor to block the call, but for some reason the call is allowed to
execute, causing the test to fail.  My test case is written as
follows:

public void test2Launches() {
                Instrumentation instr = getInstrumentation();
                IntentFilter callFilter = new IntentFilter(Intent.ACTION_CALL);
                Instrumentation.ActivityMonitor monitor =
instr.addMonitor(callFilter, null, true);
                mActivity.runOnUiThread(
                                new Runnable() {

                                        public void run() {
                                                mCallButton.requestFocus();

                                        }
                                }
                );
                this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
                assertEquals(1, monitor.getHits());
        }

Any help on why this isn't working would be appreciated.

-- 



Re: Testing with Activity Monitor

by Dianne Hackborn » Tue, 12 Apr 2011 07:28:00 GMT


 What is the error you are getting?







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 


Sponsored Links


Re: Testing with Activity Monitor

by Brian Phagan » Tue, 12 Apr 2011 07:43:43 GMT


 The Dialer activity is not blocked, it is allowed to launch.  Also,
the assertEquals(1, monitor.getHits()) fails with a value of 0.





-- 



Re: Re: Testing with Activity Monitor

by Dianne Hackborn » Tue, 12 Apr 2011 07:51:05 GMT


 Your intent filter also needs to handle CATEGORY_DEFAULT.  This should be
the exact same thing you would put in the manifest to handle an intent.









-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Re: Testing with Activity Monitor

by Brian Phagan » Tue, 12 Apr 2011 08:24:26 GMT


  have added the category to the intent filter, but still no luck.
Code now looks like this:

public void test2Launches() {
Instrumentation instr = getInstrumentation();
IntentFilter callFilter = new IntentFilter(Intent.ACTION_CALL);
callFilter.addCategory(Intent.CATEGORY_DEFAULT);
Instrumentation.ActivityMonitor monitor =
instr.addMonitor(callFilter, null, true);
assertNotNull(mCallButton);
mActivity.runOnUiThread(
new Runnable() {

public void run() {
mCallButton.requestFocus();

}
}
);
this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
assertEquals(1, monitor.getHits());
}

On Apr 11, 6:50pm, Dianne Hackborn <hack...@android.com> wrote:

--



Re: Re: Testing with Activity Monitor

by Dianne Hackborn » Tue, 12 Apr 2011 08:29:13 GMT


 hat do you see in the log as the actual intent being started?

On Mon, Apr 11, 2011 at 5:24 PM, Brian Phagan <phagan....@gmail.com> wrote:




--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.

--



Re: Testing with Activity Monitor

by Brian Phagan » Tue, 12 Apr 2011 08:41:49 GMT


 4-12 00:38:32.894: INFO/ActivityManager(59): Starting activity:
Intent { act=android.intent.action.CALL dat=tel:5733415688
cmp=com.android.phone/.OutgoingCallBroadcaster }


On Apr 11, 7:28pm, Dianne Hackborn <hack...@android.com> wrote:

--



Re: Re: Testing with Activity Monitor

by Dianne Hackborn » Tue, 12 Apr 2011 09:50:58 GMT


 o that's the intent you need to intercept -- CALL and the "tel:" scheme.
Also of course the DEFAULT category.

On Mon, Apr 11, 2011 at 5:41 PM, Brian Phagan <phagan....@gmail.com> wrote:




--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.

--



Other Threads

1. Launch Maps App with directions

Hi,

I am a mobile web developer in need of some Android expertise. I have
a web app which needs a directions button. This button needs to open
the Maps App and provide directions from the users current location to
a define dlong + lat.

At the moment I can launch the Maps App using geo:latitude,longitude
and passing in the starting address. Is there a way that I can pass in
the destination and tell the Maps App to determine the route?

Thanks in advance.

Regards,
Damjan

2. Wi-Fi problems on Moto CLIQ android 1.5 in with Armenian SIM card.

Dear Developers

I have this situation please read and not ignore maybe you can help
me.

Here 2 logs one when my sim card from Beeline AM inserted in this
state wi-fi not finding any available networks.

12-26 06:06:08.238 90 116 E WifiHW : wifi_load_driver(175) ifc_up
worked i
n 300 ms
12-26 06:06:08.248 90 116 E WifiHW : control_supplicant(270)
supplicant wp
a_supplicant sending ctl.start
12-26 06:06:09.518 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:09.528 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:09.678 597 597 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=-1 s
tate=2
12-26 06:06:09.678 597 597 I wpa_supplicant: CTRL-EVENT-SCAN-RESULTS
Ready
12-26 06:06:10.148 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:10.158 597 597 I wpa_supplicant: CTRL-EVENT-SCAN-RESULTS
Ready
12-26 06:06:10.158 597 597 I wpa_supplicant: Trying to associate with
00:1a:
70:aa:58:dc (SSID='WVA' freq=2462 MHz)
12-26 06:06:10.168 597 597 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=-1 s
tate=3
12-26 06:06:10.168 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:10.188 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:10.398 90 115 I WifiStateTracker:
setRegulatoryDomainCountry():
use coutry code from Settings: AM
12-26 06:06:20.208 597 597 I wpa_supplicant: Authentication with 00:1a:
70:aa
:58:dc timed out.
12-26 06:06:20.208 597 597 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=0 st
ate=0
12-26 06:06:20.218 597 597 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=-1 s
tate=2
12-26 06:06:20.238 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:20.238 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:20.238 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:20.258 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:20.268 597 597 I wpa_supplicant: CTRL-EVENT-SCAN-RESULTS
Ready
12-26 06:06:24.988 90 515 I ActivityManager: Starting activity: Intent
{ ac
tion=android.intent.action.MAIN comp={com.android.settings/
com.android.settings.
wifi.WifiSettings} }
12-26 06:06:25.028 90 252 I PowerManagerService: keypad run :false:0:0
12-26 06:06:25.028 90 110 I PowerManagerService: keypad run :false:0:0
12-26 06:06:25.288 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:25.288 597 597 I wpa_supplicant: CTRL-EVENT-SCAN-RESULTS
Ready
12-26 06:06:25.428 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:25.448 597 597 I wpa_supplicant: CTRL-EVENT-SCAN-RESULTS
Ready
12-26 06:06:25.948 90 111 I ActivityManager: Displayed activity
com.android
.settings/.wifi.WifiSettings: 963 ms
12-26 06:06:26.268 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:26.318 51 80 E QC-DSS-LIB: unrecognized ifindex 8
12-26 06:06:26.498 336 336 I PollingManager: connectivity_action:
NetworkInf
o: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason:
(unspecified), extra:


And the second one is after removing my sim card doing wipe format
phone and puting sim card from diferent country which can't get any
gsm signal in my country this time wi-fi finding and conecting to
network.

12-28 18:55:15.265 90 120 E WifiHW : wifi_load_driver(175) ifc_up
worked i
n 400 ms
12-28 18:55:15.265 90 120 E WifiHW : control_supplicant(270)
supplicant wp
a_supplicant sending ctl.start
12-28 18:55:15.905 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:15.925 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:16.065 461 461 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=-1 s
tate=2
12-28 18:55:16.065 461 461 I wpa_supplicant: CTRL-EVENT-SCAN-RESULTS
Ready
12-28 18:55:16.535 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:16.535 461 461 I wpa_supplicant: CTRL-EVENT-SCAN-RESULTS
Ready
12-28 18:55:16.535 461 461 I wpa_supplicant: Trying to associate with
00:1a:
70:aa:58:dc (SSID='WVA' freq=2462 MHz)
12-28 18:55:16.535 461 461 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=-1 s
tate=3
12-28 18:55:16.545 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:16.555 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:17.055 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:17.055 461 461 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=0 st
ate=4
12-28 18:55:17.055 461 461 I wpa_supplicant: Associated with 00:1a:
70:aa:58:
dc
12-28 18:55:17.065 461 461 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=0 st
ate=5
12-28 18:55:17.075 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:17.075 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:17.115 461 461 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=0 st
ate=5
12-28 18:55:17.115 461 461 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=0 st
ate=6
12-28 18:55:17.125 461 461 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=0 st
ate=6
12-28 18:55:17.125 461 461 I wpa_supplicant: WPA: Key negotiation
completed
with 00:1a:70:aa:58:dc [PTK=TKIP GTK=TKIP]
12-28 18:55:17.125 461 461 I wpa_supplicant: CTRL-EVENT-STATE-CHANGE
id=0 st
ate=7
12-28 18:55:17.125 461 461 I wpa_supplicant: CTRL-EVENT-CONNECTED -
Connecti
on to 00:1a:70:aa:58:dc completed (auth) [id=0 id_str=]
12-28 18:55:17.125 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:17.425 90 119 I WifiStateTracker:
setRegulatoryDomainCountry():
use coutry code from Settings: null
12-28 18:55:18.115 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:18.125 461 461 I wpa_supplicant: CTRL-EVENT-SCAN-RESULTS
Ready
12-28 18:55:18.645 51 80 E QC-DSS-LIB: unrecognized ifindex 7
12-28 18:55:19.845 190 190 I PollingManager: connectivity_action:
NetworkInf
o: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified),
extra:


As In understand from logs problem is country code which is in my sim
card AM and in second time it can't get any code and getting country
code null and wi-fi works.

Also there is 2 other friends who uses same phone in Brazil and
Russia. Brazil friend have same situation like mine but for Russian
freind it's working with country code RU.

Please if someone can help me I am ready to provide any logs and any
files from phone.

Thanks in advnace.

Mikayel

3. ERROR/AndroidRuntime(703): java.lang.VerifyError

4. Query on committing changes to content providers

5. android install sdk fail

6. developer reference html problem

7. keep webview in one activity