mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-05-24 17:22:49 +08:00
Merge branch 'master' into edge
This commit is contained in:
@@ -27,10 +27,10 @@ module ProMotion
|
||||
mask = UIApplication.sharedApplication.enabledRemoteNotificationTypes
|
||||
types = []
|
||||
|
||||
types << :badge if mask & UIRemoteNotificationTypeBadge
|
||||
types << :sound if mask & UIRemoteNotificationTypeSound
|
||||
types << :alert if mask & UIRemoteNotificationTypeAlert
|
||||
types << :newsstand if mask & UIRemoteNotificationTypeNewsstandContentAvailability
|
||||
types << :badge if mask & UIRemoteNotificationTypeBadge > 0
|
||||
types << :sound if mask & UIRemoteNotificationTypeSound > 0
|
||||
types << :alert if mask & UIRemoteNotificationTypeAlert > 0
|
||||
types << :newsstand if mask & UIRemoteNotificationTypeNewsstandContentAvailability > 0
|
||||
|
||||
types
|
||||
end
|
||||
@@ -53,9 +53,9 @@ module ProMotion
|
||||
def application(application, didReceiveRemoteNotification:notification)
|
||||
received_push_notification(notification, application.applicationState != UIApplicationStateActive)
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
|
||||
|
||||
def map_notification_symbol(symbol)
|
||||
{
|
||||
none: UIRemoteNotificationTypeNone,
|
||||
|
||||
@@ -52,5 +52,14 @@ module ProMotion
|
||||
@params
|
||||
end
|
||||
|
||||
def method_missing(meth, *args)
|
||||
if @params[meth.to_sym]
|
||||
@params[meth.to_sym]
|
||||
else
|
||||
PM.logger.warn "The annotation parameter \"#{meth}\" does not exist on this pin."
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,8 +32,8 @@ describe "ProMotion::TestMapScreen functionality" do
|
||||
|
||||
it "should have the map properly centered" do
|
||||
center_coordinate = @map.center
|
||||
center_coordinate.latitude.should.be.close 35.090648651123, 0.001
|
||||
center_coordinate.longitude.should.be.close -82.965972900391, 0.001
|
||||
center_coordinate.latitude.should.be.close 35.090648651123, 0.02
|
||||
center_coordinate.longitude.should.be.close -82.965972900391, 0.02
|
||||
end
|
||||
|
||||
it "should move the map center" do
|
||||
|
||||
@@ -27,6 +27,24 @@ describe "PM::Delegate" do
|
||||
|
||||
end
|
||||
|
||||
it "should return the registered push notification types as an array" do
|
||||
@subject.registered_push_notifications.should == []
|
||||
bits = 0
|
||||
types = []
|
||||
{ badge: UIRemoteNotificationTypeBadge,
|
||||
sound: UIRemoteNotificationTypeSound,
|
||||
alert: UIRemoteNotificationTypeAlert,
|
||||
newsstand: UIRemoteNotificationTypeNewsstandContentAvailability }.each do |symbol, bit|
|
||||
UIApplication.sharedApplication.stub!(:enabledRemoteNotificationTypes, return: bit)
|
||||
@subject.registered_push_notifications.should == [symbol]
|
||||
|
||||
bits |= bit
|
||||
types << symbol
|
||||
UIApplication.sharedApplication.stub!(:enabledRemoteNotificationTypes, return: bits)
|
||||
@subject.registered_push_notifications.should == types
|
||||
end
|
||||
end
|
||||
|
||||
it "should return false for was_launched if the app is currently active on screen" do
|
||||
@subject.mock!(:on_push_notification) do |notification, was_launched|
|
||||
was_launched.should.be.false
|
||||
|
||||
@@ -30,6 +30,28 @@ describe "map properties" do
|
||||
@map.annotations.count.should == 6
|
||||
end
|
||||
|
||||
it "should return custom annotation parameters" do
|
||||
ann = {
|
||||
longitude: -82.966093558105,
|
||||
latitude: 35.092520895652,
|
||||
title: "Custom",
|
||||
another_value: "Mark"
|
||||
}
|
||||
@map.add_annotation(ann)
|
||||
@map.annotations.last.another_value.should == "Mark"
|
||||
end
|
||||
|
||||
it "should return nil for custom annotation parameters that don't exist" do
|
||||
ann = {
|
||||
longitude: -82.966093558105,
|
||||
latitude: 35.092520895652,
|
||||
title: "Custom",
|
||||
another_value: "Mark"
|
||||
}
|
||||
@map.add_annotation(ann)
|
||||
@map.annotations.last.another_value_fake.should == nil
|
||||
end
|
||||
|
||||
it "should clear annotations" do
|
||||
@map.clear_annotations
|
||||
@map.annotations.count.should == 0
|
||||
|
||||
Reference in New Issue
Block a user