Package ns.foundation

Examples of ns.foundation.NSNotificationCenter.postNotification()


  public void testPostNotificationNSNotification() {
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
    TestObserver observer = new TestObserver();
    nc.addObserver(observer, new NSSelector<Void>("invoked", new Class[] { NSNotification.class }), "test", null);
    NSNotification notification = new NSNotification("test", null);
    nc.postNotification(notification);
    assertTrue(observer.invoked);
  }

  public void testPostNotificationStringObject() {
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
View Full Code Here


  public void testPostNotificationStringObject() {
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
    TestObserver observer = new TestObserver();
    nc.addObserver(observer, new NSSelector<Void>("invoked", new Class[] { NSNotification.class }), "test", null);
    nc.postNotification("test", this);
    assertTrue(observer.invoked);
  }

  public void testPostNotificationStringObjectNSDictionaryOfStringObject() {
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
View Full Code Here

  public void testPostNotificationStringObjectNSDictionaryOfStringObject() {
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
    TestObserver observer = new TestObserver();
    nc.addObserver(observer, new NSSelector<Void>("invoked", new Class[] { NSNotification.class }), "test", null);
    NSDictionary<String, Object> userInfo = new NSDictionary<String, Object>("value", "key");
    nc.postNotification("test", this, userInfo);
    assertTrue(observer.invoked);
    assertEquals(userInfo, observer.userInfo);
  }

  public void testRemoveObserverObject() {
View Full Code Here

  public void testRemoveObserverObject() {
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
    TestObserver observer = new TestObserver();
    nc.addObserver(observer, new NSSelector<Void>("invoked", new Class[] { NSNotification.class }), "test", null);
    nc.removeObserver(observer);
    nc.postNotification("test", this);
    assertFalse(observer.invoked);
  }

  public void testRemoveObserverObjectStringObject() {
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
View Full Code Here

    TestObserver observer1 = new TestObserver();
    TestObserver observer2 = new TestObserver();
    nc.addObserver(observer1, new NSSelector<Void>("invoked", new Class[] { NSNotification.class }), "test", null);
    nc.addObserver(observer2, new NSSelector<Void>("invoked", new Class[] { NSNotification.class }), "test", null);
    nc.removeObserver(observer2, "test", null);
    nc.postNotification("test", this);
    assertTrue(observer1.invoked);
    assertFalse(observer2.invoked);
  }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.