当前位置: 编程技术>移动开发
本页文章导读:
▪PC端透过adb与设备端通信 PC端通过adb与设备端通信
adb 全称Android Debug Bridge, 是android sdk里的一个工具, 用这个工具可以直接操作管理android模拟器或者真实的andriod设备(如G1手机).它的主要功能有:
运行设备的.........
▪ 当唯有一个APK的时候使用robotium进行自动化测试 当只有一个APK的时候使用robotium进行自动化测试
一. 准备工具
3. 搭建测试环境
01
<?xml version="1.0" encoding="utf-8"?>
02
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
.........
▪ 在MKMapView中设立区域显示所有注释 在MKMapView中设置区域显示所有注释原问题来自于CSDN问答频道,更多见:http://ask.csdn.net/questions/2005
问题描述:
有10-15个经纬度需要同时显示在地图上,怎么设置区域这样可以在地图中看到所.........
[1]PC端透过adb与设备端通信
来源: 互联网 发布时间: 2014-02-18
PC端通过adb与设备端通信
adb 全称Android Debug Bridge, 是android sdk里的一个工具, 用这个工具可以直接操作管理android模拟器或者真实的andriod设备(如G1手机).
它的主要功能有:
- 运行设备的shell(命令行)
- 管理模拟器或设备的端口映射
- 计算机和设备之间上传/下载文件
- 将本地apk软件安装至模拟器或android设备
adb是一个 客户端-服务器端 程序, 其中客户端是你用来操作的电脑, 服务器端是android设备.
一 adb Client 及 adb Server
上图开启了两个adb client,一个adb server。
当开启第一个adb client 时,检测到adb server没有开启,于是开启adb server(只用一个),接着开启第二个adb client。
二 PC端 通过adb 与设备端进行通信
[2] 当唯有一个APK的时候使用robotium进行自动化测试
来源: 互联网 发布时间: 2014-02-18
当只有一个APK的时候使用robotium进行自动化测试
一. 准备工具
一. 准备工具
1. 准备重签名工具:http://www.troido.de/re-sign.jar(在mac上没办法用,只能在windows上用)
2. 下载robotium.jar http://code.google.com/p/robotium/downloads/list
3. 搭建测试环境
二. AndroidManifest.xml
01
<?xml version="1.0" encoding="utf-8"?>
02
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
03
package="com.taobao.taobao.test"
04
android:versionCode="1"
05
android:versionName="1.0" >
06
07
<uses-sdk android:minSdkVersion="8" />
08
09
<instrumentation
10
android:name="android.test.InstrumentationTestRunner"
11
android:targetPackage="com.taobao.taobao" />
12
13
<application
14
android:icon="@drawable/ic_launcher"
15
android:label="@string/app_name" >
16
<uses-library android:name="android.test.runner" />
17
</application>
18
19
</manifest>
三. TestGarblePackage.java
01
package com.taobao.taobao.test;
02
03
import android.test.ActivityInstrumentationTestCase2;
04
05
import com.jayway.android.robotium.solo.Solo;
06
07
/**
08
*
测试混淆包
09
*
10
*
@author bixiaopeng 2013-4-8 下午1:26:15
11
*/
12
@SuppressWarnings("rawtypes")
13
public class TestGarblePackage extends ActivityInstrumentationTestCase2
{
14
15
private Solo
solo;
16
private static Class<?>
launchActivityClass;
17
private static String
mainActivity = "com.taobao.tao.MainActivity2"; //
启动的类名
18
static {
19
try {
20
launchActivityClass
= Class.forName(mainActivity);//
通过反射来获取activity
21
} catch (ClassNotFoundException
e) {
22
throw new RuntimeException(e);
23
}
24
25
}
26
27
@SuppressWarnings("unchecked")
28
public TestGarblePackage(){
29
super(launchActivityClass);
30
}
31
32
@Override
33
protected void setUp() throws Exception
{
34
solo
= new Solo(getInstrumentation(),
getActivity());
35
}
36
37
@Override
38
protected void tearDown() throws Exception
{
39
solo.finishOpenedActivities();
40
}
41
42
public void testUpdate() throws Exception
{
43
solo.clickOnMenuItem("检测更新");
44
//
robotium好像没有直接提供获取toast的方法,所以只用个笨方法
45
int i
= 0;
46
boolean toast
= false;
47
while (i
< 40)
{
48
Thread.sleep(300);
49
toast
= solo.searchText("您使用的版本已是最新的了哦");
50
if (toast)
{
51
break;
52
}
53
i++;
54
}
55
assertEquals(toast, true);
56
}
57
}
[3] 在MKMapView中设立区域显示所有注释
来源: 互联网 发布时间: 2014-02-18
在MKMapView中设置区域显示所有注释
原问题来自于CSDN问答频道,更多见:http://ask.csdn.net/questions/2005
问题描述:
有10-15个经纬度需要同时显示在地图上,怎么设置区域这样可以在地图中看到所有的注释?
:
create class as below. create two class: ViewController is class of UIViewController and MapViewAnnotation is class of NSObject. I have created that two class as below. bind mapview in XIB of ViewController and set delegate.
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import "MapViewAnnotation.h"
@interface ViewController : UIViewController<MKMapViewDelegate>{
IBOutlet MKMapView* mapView;
NSMutableArray *arrayLocation;
}
@end
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
arrayLocation = [[NSMutableArray alloc]init];
NSMutableArray *arrAnnotations = [[NSMutableArray alloc]init];
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setValue:@"32.774125" forKey:@"latitude"];
[dict setValue:@"-117.240658" forKey:@"longitude"];
[dict setValue:@"Bars & Restaurants 1" forKey:@"title"];
[arrayLocation addObject:dict];
dict = nil;
dict = [[NSMutableDictionary alloc]init];
[dict setValue:@"32.784526" forKey:@"latitude"];
[dict setValue:@"-117.240985" forKey:@"longitude"];
[dict setValue:@"Bars & Restaurants 2" forKey:@"title"];
[arrayLocation addObject:dict];
dict = nil;
dict = [[NSMutableDictionary alloc]init];
[dict setValue:@"32.773477" forKey:@"latitude"];
[dict setValue:@"-117.241144" forKey:@"longitude"];
[dict setValue:@"Bars & Restaurants 3" forKey:@"title"];
[arrayLocation addObject:dict];
dict = nil;
dict = [[NSMutableDictionary alloc]init];
[dict setValue:@"32.775301" forKey:@"latitude"];
[dict setValue:@"-117.238893" forKey:@"longitude"];
[dict setValue:@"Bars & Restaurants 4" forKey:@"title"];
[arrayLocation addObject:dict];
dict = nil;
for(int i=0;i<[arrayLocation count];i++)
{
CLLocationCoordinate2D location;
location.latitude = [[[arrayLocation objectAtIndex:i] objectForKey:@"latitude"] doubleValue];
location.longitude = [[[arrayLocation objectAtIndex:i] objectForKey:@"longitude"] doubleValue];
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:[[arrayLocation objectAtIndex:i] objectForKey:@"title"] Coordinate:location andIndex:i];
[arrAnnotations addObject:newAnnotation];
}
[mapView addAnnotations:arrAnnotations];
mapView.region = [MapViewAnnotation regionForAnnotations:arrAnnotations];
}
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
if (annotation == mapView.userLocation)
{
return nil;
}
MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"restMap"];
if (pin == nil)
{
pin = [[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"restMap"];
}
else
{
pin.annotation = annotation;
}
pin.pinColor = MKPinAnnotationColorRed;
pin.animatesDrop = NO;
pin.canShowCallout=TRUE;
UIButton *btn=[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
MapViewAnnotation *temp = (MapViewAnnotation *)pin.annotation;
btn.tag=temp.index;
pin.rightCalloutAccessoryView=btn;
[btn addTarget:self action:@selector(openDetail:) forControlEvents:UIControlEventTouchUpInside];
return pin;
}
@end
Implementation of MapViewAnnotation class
#import <MapKit/MapKit.h>
@interface MapViewAnnotation : NSObject <MKAnnotation , MKMapViewDelegate>{
NSString *title;
int index;
CLLocationCoordinate2D coordinate;
}
@property (nonatomic, copy) NSString *title;
@property (nonatomic, readwrite) int index;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d;
- (id)initWithTitle:(NSString *)ttl Coordinate:(CLLocationCoordinate2D)c2d andIndex:(int)intIndex;
+(MKCoordinateRegion) regionForAnnotations:(NSArray*) annotations ;
@end
#import "MapViewAnnotation.h"
@implementation MapViewAnnotation
@synthesize title, coordinate,index;
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d {
self = [super init];
title = ttl;
coordinate = c2d;
return self;
}
- (id)initWithTitle:(NSString *)ttl Coordinate:(CLLocationCoordinate2D)c2d andIndex:(int)intIndex
{
self = [super init];
title = ttl;
coordinate = c2d;
index = intIndex;
return self;
}
+(MKCoordinateRegion) regionForAnnotations:(NSArray*) annotations
{
NSAssert(annotations!=nil, @"annotations was nil");
NSAssert([annotations count]!=0, @"annotations was empty");
double minLat=360.0f, maxLat=-360.0f;
double minLon=360.0f, maxLon=-360.0f;
for (id<MKAnnotation> vu in annotations) {
if ( vu.coordinate.latitude < minLat ) minLat = vu.coordinate.latitude;
if ( vu.coordinate.latitude > maxLat ) maxLat = vu.coordinate.latitude;
if ( vu.coordinate.longitude < minLon ) minLon = vu.coordinate.longitude;
if ( vu.coordinate.longitude > maxLon ) maxLon = vu.coordinate.longitude;
}
CLLocationCoordinate2D center = CLLocationCoordinate2DMake((minLat+maxLat)/2.0, (minLon+maxLon)/2.0);
MKCoordinateSpan span = MKCoordinateSpanMake(maxLat-minLat, maxLon-minLon);
MKCoordinateRegion region = MKCoordinateRegionMake (center, span);
return region;
}
@end
最新技术文章: