Ejemplo n.º 1
0
static void
gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
                              GtkNotebookPage *page,
                              gint WXUNUSED(page_num),
                              wxMDIParentFrame *parent )
{
    // send deactivate event to old child

    wxMDIChildFrame *child = parent->GetActiveChild();
    if (child)
    {
        wxActivateEvent event1( wxEVT_ACTIVATE, false, child->GetId() );
        event1.SetEventObject( child);
        child->HandleWindowEvent( event1 );
    }

    // send activate event to new child

    wxMDIClientWindowBase *client_window = parent->GetClientWindow();
    if ( !client_window )
        return;

    child = NULL;

    wxWindowList::compatibility_iterator node = client_window->GetChildren().GetFirst();
    while ( node )
    {
        wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame );

        // child_frame can be NULL when this is called from dtor, probably
        // because g_signal_connect (m_widget, "switch_page", (see below)
        // isn't deleted early enough
        if ( child_frame && child_frame->m_page == page )
        {
            child = child_frame;
            break;
        }
        node = node->GetNext();
    }

    if (!child)
         return;

    wxActivateEvent event2( wxEVT_ACTIVATE, true, child->GetId() );
    event2.SetEventObject( child);
    child->HandleWindowEvent( event2 );
}
Ejemplo n.º 2
0
void CMouseMoveMap::slotMoveWpt()
{
    if(selWpts.isEmpty()) return;
    canvas->setMouseMode(CCanvas::eMouseMoveWpt);

    CWpt * selWpt = selWpts.first().wpt;

    double u = selWpt->lon * DEG_TO_RAD;
    double v = selWpt->lat * DEG_TO_RAD;
    CMapDB::self().getMap().convertRad2Pt(u,v);

    QMouseEvent event1(QEvent::MouseMove, QPoint(u,v), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
    QCoreApplication::sendEvent(canvas,&event1);

    QMouseEvent event2(QEvent::MouseButtonPress, QPoint(u,v), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
    QCoreApplication::sendEvent(canvas,&event2);
}
static void *dchan(void *data)
{
	/* Joint D-channel */
	struct pri *pri = data;
	struct timeval *next, tv;
	pri_event *e;
	fd_set fds;
	int res;
	for(;;) {
		if ((next = pri_schedule_next(pri))) {
			gettimeofday(&tv, NULL);
			tv.tv_sec = next->tv_sec - tv.tv_sec;
			tv.tv_usec = next->tv_usec - tv.tv_usec;
			if (tv.tv_usec < 0) {
				tv.tv_usec += 1000000;
				tv.tv_sec -= 1;
			}
			if (tv.tv_sec < 0) {
				tv.tv_sec = 0;
				tv.tv_usec = 0;
			}
		}
		FD_ZERO(&fds);
		FD_SET(pri_fd(pri), &fds);
		res = select(pri_fd(pri) + 1, &fds, NULL, NULL, next ? &tv : NULL);
		pthread_mutex_lock(&lock);
		cur = pri;
		if (res < 0) {
			perror("select");
		} else if (!res) {
			e = pri_schedule_run(pri);
		} else {
			e = pri_check_event(pri);
		}
		if (e) {
			if (first == pri) {
				event1(pri, e);
			} else {
				event2(pri, e);
			}
		}
		pthread_mutex_unlock(&lock);
	}
	return NULL;
}
Ejemplo n.º 4
0
static void
generate_events (void)
{
  struct lwes_emitter *emitter;

  /* create emitter */
  emitter = lwes_emitter_create (TEST_LLOG_ADDRESS,
                                 TEST_LLOG_INTERFACE,
                                 atoi (TEST_LLOG_PORT),
                                 0,
                                 60);

  MY_ASSERT (emitter != NULL);

  event1 (emitter);

  lwes_emitter_destroy (emitter);
}
Ejemplo n.º 5
0
void VirtualProcessor::run() {
	bool should_create_more_work = false;
	while (true) {
		//daemon->get_job(this, NULL);
		VPEvent event(GetJob, this, daemon, NULL);
		daemon->push_event(event);
		block();
		if (!current_job) {
			break;
		}

		current_job->run();
		//daemon->get_job(this, current_job);
		VPEvent event1(EndOfJob, this, daemon, current_job);
		daemon->push_event(event1);
		block();
		current_job = NULL;
	}
}
Ejemplo n.º 6
0
void ComponentEventTest::testConvertValue()
{
  std::map<std::string, std::string> attributes;
  attributes["id"] = "1";
  attributes["name"] = "DataItemTest1";
  attributes["type"] = "ACCELERATION";
  attributes["category"] = "SAMPLE";

  std::string time("NOW"), value("2.0");
  
  attributes["nativeUnits"] = "REVOLUTION/MINUTE";
  DataItem data1 (attributes);
  ComponentEvent event1(data1, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f, event1.getFValue());
  CPPUNIT_ASSERT(event1.getSValue().empty());
  
  attributes["nativeUnits"] = "REVOLUTION/SECOND";
  DataItem data2 (attributes);
  ComponentEvent event2 (data2, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 60.0f, event2.getFValue());
  CPPUNIT_ASSERT(event2.getSValue().empty());
  
  attributes["nativeUnits"] = "GRAM/INCH";
  DataItem data3 (attributes);
  ComponentEvent event3 (data3, 123, time, value);
  CPPUNIT_ASSERT_EQUAL((2.0f / 1000.0f) / 25.4f, event3.getFValue());
  CPPUNIT_ASSERT(event3.getSValue().empty());
  
  attributes["nativeUnits"] = "MILLIMETER/MINUTE^3";
  DataItem data4 (attributes);
  ComponentEvent event4 (data4, 123, time, value);
  CPPUNIT_ASSERT_EQUAL((2.0f) / (60.0f * 60.0f * 60.0f), event4.getFValue());
  CPPUNIT_ASSERT(event4.getSValue().empty());
  
  attributes["nativeUnits"] = "MILLIMETER/MINUTE^3";
  attributes["nativeScale"] = "0.5";
  DataItem data5 (attributes);
  ComponentEvent event5 (data5, 123, time, value);
  CPPUNIT_ASSERT_EQUAL((2.0f) / (60.0f * 60.0f * 60.0f * 0.5f),
    event5.getFValue());
  CPPUNIT_ASSERT(event5.getSValue().empty());
}
Ejemplo n.º 7
0
void TestEITFixups::testUKFixups1()
{
    EITFixUp fixup;

    DBEventEIT event1(11381,
                      "Book of the Week",
                      "Girl in the Dark: Anna Lyndsey's account of finding light in the darkness after illness changed her life. 3/5. A Descent into Darkness: The disquieting persistence of the light.",
                      QDateTime::fromString("2015-03-05T00:30:00Z", Qt::ISODate),
                      QDateTime::fromString("2015-03-05T00:48:00Z", Qt::ISODate),
                      EITFixUp::kFixGenericDVB | EITFixUp::kFixUK,
                      SUB_UNKNOWN,
                      AUD_STEREO,
                      VID_UNKNOWN);

    fixup.Fix(event1);

    PRINT_EVENT(event1);
    QCOMPARE(event1.episode,       3u);
    QCOMPARE(event1.totalepisodes, 5u);
}
void UT_CMceStateServerEstablishing::UT_CMceStateServerEstablishing_AcceptLL()
    {
    TMceIds ids;
    CMceMsgBase* msg = NULL;

    TMceStateTransitionEvent event1( *iSipSession, EMceItcUpdate, ids, *msg );
    EUNIT_ASSERT ( iState->AcceptL( event1 ) );

    TMceStateTransitionEvent event2( *iSipSession, EMceItcRejectSession, ids, *msg  );
    EUNIT_ASSERT ( iState->AcceptL( event2 ) );
 
    TMceStateTransitionEvent event3( *iSipSession, EMceMediaSessionStopped );
    TRAPD( e1, iState->AcceptL( event3 ) );
    EUNIT_ASSERT ( e1 == KErrTotalLossOfPrecision );

    TMceStateTransitionEvent event4( *iSipSession, EMceResponse );
    TRAPD( e2, iState->AcceptL( event4 ) );
    EUNIT_ASSERT ( e2 == KErrTotalLossOfPrecision );
    
    }
Ejemplo n.º 9
0
void EventSpyTest::testEventReceivedSeveralObjects() {
    EventSpy spy;
    QObject spiedObject1;
    spy.addObjectToSpy(&spiedObject1);
    QObject spiedObject2;
    spy.addObjectToSpy(&spiedObject2);

    QSignalSpy eventEmittedSpy(&spy, SIGNAL(eventReceived(QObject*,QEvent*)));

    //Send an event not managed by QObject to avoid messing up its internal
    //state
    QEvent event1(QEvent::Show);
    QApplication::sendEvent(&spiedObject1, &event1);
    QEvent event2(QEvent::Show);
    QApplication::sendEvent(&spiedObject2, &event2);

    QCOMPARE(eventEmittedSpy.count(), 2);
    assertEventReceivedSignal(eventEmittedSpy, 0, &spiedObject1, &event1);
    assertEventReceivedSignal(eventEmittedSpy, 1, &spiedObject2, &event2);
}
Ejemplo n.º 10
0
int main()
{
	EventQueue event = *EventQueue::getInstance();
	Event event1("H1"), event2("H2"), event3("H3"), event4("H4"), event5("H5");
	
	event1.time = 0.5;
	event2.time = 0.6;
	event3.time = 0.3;

	event.push(&event1); 
	event.push(&event2);
	event.push(&event3);
	
	//the order now should be 0.3/0.5/0.6
	assert(event.pop()->time == 0.3);

	event4.time = 1;
	event5.time = 0.1;

	event.push(&event4);
	event.push(&event5);

	//the order should now be 0.1/0.5/0.6/1
	assert(event.pop()->time == 0.1);
	assert(event.pop()->time == 0.5);
	assert(event.pop()->time == 0.6);
	assert(event.pop()->time == 1);

	//if nothing is in the event, return "-1"
	assert(event.pop()->time == -1); 
	assert(event.pop()->time == -1);

	printf("Test Success - event queue\n");

	return EXIT_SUCCESS;
}
void UT_CMceStateServerEstablishing::UT_CMceStateServerEstablishing_ExitLL()
    {
    CMceMsgBase* msg = NULL;
    
    iSipSession->iBody = CMceComSession::NewL( CMceComSession::EInSession );
    iSipSession->iSubState = CMceSipSession::EAnswering;
    
    
    
    TMceIds ids;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateServerEstablishing );
    
    
    ids.iState = KMceNotAssigned;
    TMceStateTransitionEvent event1( *iSipSession, EMceItcUpdate, ids, *msg );
    
    iSipSession->iSubState = CMceSipSession::EAnswering;
    event1.ParamStatus() = KMceReady;
    
    iState->ExitL( event1 );
	EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateUpdated );
	EUNIT_ASSERT ( ids.iState == CMceSession::EReserving );
	EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EProceeding );

    TMceStateTransitionEvent event1_2( *iSipSession, EMceItcUpdate, ids, *msg );
    
    iSipSession->iSubState = CMceSipSession::EUpdating;
    event1.ParamStatus() = KMceReady;

    iState->ExitL( event1_2 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateAnswering );
    EUNIT_ASSERT ( ids.iState == CMceSession::EAnswering );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EAnswering );

    TMceStateTransitionEvent event1_3( *iSipSession, EMceItcUpdate, ids, *msg );
    
    iSipSession->iSubState = CMceSipSession::EUpdating;
    event1.ParamStatus() = KMceReady;
    
    CSIPServerTransaction* update = MCETestHelper::ServerTransactionL( SipStrConsts::EUpdate );
    CleanupStack::PushL( update );
    iSipSession->iPendingReceivedRequests.AppendL( update );
    CleanupStack::Pop( update );

    iState->ExitL( event1_3 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateEstablished );
    EUNIT_ASSERT ( ids.iState == CMceSession::EEstablished );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EEstablished );
    delete iSipSession->PopRequest();

    ids.iState = KMceNotAssigned;
    TMceStateTransitionEvent event2( *iSipSession, EMceItcUpdate, ids, *msg );
    
    iSipSession->iSubState = CMceSipSession::EAnswering;
    event2.ParamStatus() = KMceAsync;
    
    iState->ExitL( event2 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateUpdating );
    EUNIT_ASSERT ( ids.iState == CMceSession::EReserving );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EReserving );

    ids.iState = KMceNotAssigned;
    TMceStateTransitionEvent event3( *iSipSession, EMceItcUpdate, ids, *msg );
    
    iSipSession->iSubState = CMceSipSession::EUpdating;
    event3.ParamStatus() = KErrGeneral;
    
    iState->ExitL( event3 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateEstablished );
    EUNIT_ASSERT ( ids.iState == CMceSession::EEstablished );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EEstablished );

 
    ids.iState = KMceNotAssigned;
    TMceStateTransitionEvent event4( *iSipSession, EMceItcRejectSession, ids );
    
    iSipSession->iSubState = CMceSipSession::EAnswering;
    
    iState->ExitL( event4 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateTerminated );
    EUNIT_ASSERT ( ids.iState == CMceSession::ETerminated );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::ETerminated );

    ids.iState = KMceNotAssigned;
    TMceStateTransitionEvent event5( *iSipSession, EMceItcRejectSession, ids );
    
    iSipSession->iSubState = CMceSipSession::EUpdating;
    
    iState->ExitL( event5 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateEstablished );
    EUNIT_ASSERT ( ids.iState == CMceSession::EEstablished );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EEstablished );


    TMceStateTransitionEvent event6( *iSipSession, EMceItcRing, ids );
    iState->ExitL( event6 );

    
    }
Ejemplo n.º 12
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  TAO_EC_Default_Factory::init_svcs ();

  try
    {
      // ORB initialization boiler plate...
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) == -1)
        {
          ACE_ERROR ((LM_ERROR,
                      "Usage: Service [-o IOR_file_name]\n"));
          return 1;
        }

      CORBA::Object_var object =
        orb->resolve_initial_references ("RootPOA");
      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (object.in ());
      PortableServer::POAManager_var poa_manager =
        poa->the_POAManager ();
      poa_manager->activate ();

      // ****************************************************************

#if 0
      // Obtain a reference to the naming service...
      CORBA::Object_var naming_obj =
        orb->resolve_initial_references ("NameService");

      CosNaming::NamingContext_var naming_context =
        CosNaming::NamingContext::_narrow (naming_obj.in ());
#endif /* 0 */

      // ****************************************************************

      // Create an scheduling service
      POA_RtecScheduler::Scheduler* sched_impl = 0;
      if (config_run)
        {
          ACE_NEW_RETURN (sched_impl,
                          RECONFIG_SCHED_TYPE,
                          1);
        }
      else
        {
          ACE_NEW_RETURN (sched_impl,
                          RECONFIG_SCHED_TYPE (configs_size,
                                               configs,
                                               infos_size,
                                               infos,
                                               0, 0,
                                               0),
                          1);
        }

      RtecScheduler::Scheduler_var scheduler =
        sched_impl->_this ();

#if 0
      // Bind the scheduler with the naming service so clients
      // (consumers and suppliers) can resolve it, some (old)
      // implementations of the EC will try to do the same thing
      // (yikes!)
      CosNaming::Name schedule_name (1);
      schedule_name.length (1);
      schedule_name[0].id = CORBA::string_dup ("ScheduleService");
      // Register the servant with the Naming Context....
      naming_context->rebind (schedule_name, scheduler.in ());
#endif /* 0 */

      // ****************************************************************

      TAO_EC_Event_Channel_Attributes attributes (poa.in (),
                                                  poa.in ());
      attributes.scheduler = scheduler.in (); // no need to dup

      TAO_EC_Event_Channel ec_impl (attributes);
      ACE_DEBUG ((LM_DEBUG, "activating EC\n"));
      ec_impl.activate ();
      ACE_DEBUG ((LM_DEBUG, "EC activated\n"));

      RtecEventChannelAdmin::EventChannel_var event_channel =
        ec_impl._this ();

      // ****************************************************************

      // Create a consumer, intialize its RT_Info structures, and
      // connnect to the event channel....

      Consumer consumer_impl;

      RtecScheduler::handle_t consumer_rt_info1 =
        scheduler->create ("consumer_event_1");

      // Let's say that the execution time for event 1 is 2
      // milliseconds...
      ACE_Time_Value tv (0, 2000);
      TimeBase::TimeT time;
      ORBSVCS_Time::Time_Value_to_TimeT (time, tv);
      scheduler->set (consumer_rt_info1,
                      RtecScheduler::VERY_HIGH_CRITICALITY,
                      time, time, time,
                      0,
                      RtecScheduler::VERY_LOW_IMPORTANCE,
                      time,
                      0,
                      RtecScheduler::OPERATION);

      RtecScheduler::handle_t consumer_rt_info2 =
        scheduler->create ("consumer_event_2");

      // Let's say that the execution time for event 2 is 1
      // milliseconds...
      tv.set (0, 1000);
      ORBSVCS_Time::Time_Value_to_TimeT (time, tv);
      scheduler->set (consumer_rt_info2,
                      RtecScheduler::VERY_LOW_CRITICALITY,
                      time, time, time,
                      0,
                      RtecScheduler::VERY_LOW_IMPORTANCE,
                      time,
                      0,
                      RtecScheduler::OPERATION);

      ACE_ConsumerQOS_Factory consumer_qos;
      consumer_qos.start_disjunction_group ();
      // The types int the range [0,ACE_ES_EVENT_UNDEFINED) are
      // reserved for the EC...
      consumer_qos.insert_type (ACE_ES_EVENT_UNDEFINED,
                                consumer_rt_info1);
      consumer_qos.insert_type (ACE_ES_EVENT_UNDEFINED + 1,
                                consumer_rt_info2);

      // The canonical protocol to connect to the EC
      RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin =
        event_channel->for_consumers ();

      RtecEventChannelAdmin::ProxyPushSupplier_var supplier_proxy =
        consumer_admin->obtain_push_supplier ();

      RtecEventComm::PushConsumer_var consumer =
        consumer_impl._this ();

      ACE_DEBUG ((LM_DEBUG, "connecting consumer\n"));
      supplier_proxy->connect_push_consumer (consumer.in (),
                                             consumer_qos.get_ConsumerQOS ());
      ACE_DEBUG ((LM_DEBUG, "consumer connected\n"));

      // ****************************************************************

      Supplier supplier_impl;

      RtecScheduler::handle_t supplier_rt_info1 =
        scheduler->create ("supplier_event_1");

      // The execution times are set to reasonable values, but
      // actually they are changed on the real execution, i.e. we
      // lie to the scheduler to obtain right priorities; but we
      // don't care if the set is schedulable.
      tv.set (0, 10000);
      TimeBase::TimeT tmp;
      ORBSVCS_Time::Time_Value_to_TimeT (tmp, tv);
      RtecScheduler::Period_t rate = ACE_U64_TO_U32(tmp);

      scheduler->set (supplier_rt_info1,
                      RtecScheduler::VERY_HIGH_CRITICALITY,
                      0, 0, 0,
                      rate,
                      RtecScheduler::VERY_LOW_IMPORTANCE,
                      0,
                      1,
                      RtecScheduler::OPERATION);

      RtecScheduler::handle_t supplier_rt_info2 =
        scheduler->create ("supplier_event_2");

      // The execution times are set to reasonable values, but
      // actually they are changed on the real execution, i.e. we
      // lie to the scheduler to obtain right priorities; but we
      // don't care if the set is schedulable.
      tv.set (0, 20000);
      ORBSVCS_Time::Time_Value_to_TimeT (tmp, tv);
      rate = ACE_U64_TO_U32(tmp);

      scheduler->set (supplier_rt_info2,
                      RtecScheduler::VERY_HIGH_CRITICALITY,
                      0, 0, 0,
                      rate,
                      RtecScheduler::VERY_LOW_IMPORTANCE,
                      0,
                      1,
                      RtecScheduler::OPERATION);

      RtecEventComm::EventSourceID supplier_id = 1;
      ACE_SupplierQOS_Factory supplier_qos;
      supplier_qos.insert (supplier_id,
                           ACE_ES_EVENT_UNDEFINED,
                           supplier_rt_info1,
                           1 /* number of calls, but what does that mean? */);
      supplier_qos.insert (supplier_id,
                           ACE_ES_EVENT_UNDEFINED + 1,
                           supplier_rt_info2,
                           1 /* number of calls, but what does that mean? */);

      // The canonical protocol to connect to the EC
      RtecEventChannelAdmin::SupplierAdmin_var supplier_admin =
        event_channel->for_suppliers ();

      RtecEventChannelAdmin::ProxyPushConsumer_var consumer_proxy =
        supplier_admin->obtain_push_consumer ();

      RtecEventComm::PushSupplier_var supplier =
        supplier_impl._this ();

      ACE_DEBUG ((LM_DEBUG, "connecting supplier\n"));
      consumer_proxy->connect_push_supplier (supplier.in (),
                                             supplier_qos.get_SupplierQOS ());
      ACE_DEBUG ((LM_DEBUG, "supplier connected\n"));

      // ****************************************************************

      // At this point the consumer and supplier are connected to the
      // EC, they have provided their QoS info to the Scheduling
      // Service and the EC has informed the Scheduler about the
      // dependencies between them.
      // We can now compute the schedule for this configuration...

      // The schedule is returned in this variables....

      if (config_run)
        {
          ACE_DEBUG ((LM_DEBUG, "Computing schedule\n"));
          RtecScheduler::RT_Info_Set_var infos;
          RtecScheduler::Dependency_Set_var deps;
          RtecScheduler::Config_Info_Set_var configs;
          RtecScheduler::Scheduling_Anomaly_Set_var anomalies;

          // Obtain the range of valid priorities in the current
          // platform, the scheduler hard-code this values in the
          // generated file, but in the future we may just use the
          // "logical" priorities and define the mapping to OS
          // priorities at run-time.
          int min_os_priority =
            ACE_Sched_Params::priority_min (ACE_SCHED_FIFO,
                                            ACE_SCOPE_THREAD);
          int max_os_priority =
            ACE_Sched_Params::priority_max (ACE_SCHED_FIFO,
                                            ACE_SCOPE_THREAD);
          scheduler->compute_scheduling (min_os_priority,
                                         max_os_priority,
                                         infos.out (),
                                         deps.out (),
                                         configs.out (),
                                         anomalies.out ());

          // Dump the schedule to a file..
          ACE_Scheduler_Factory::dump_schedule (infos.in (),
                                                deps.in (),
                                                configs.in (),
                                                anomalies.in (),
                                                ACE_TEXT("schedule.out"));
        }

      // ****************************************************************

      ACE_DEBUG ((LM_DEBUG, "Pushing events\n"));

      // Generate a few events....

      RtecEventComm::EventSet event1 (1);
      event1.length (1);
      event1[0].header.type   = ACE_ES_EVENT_UNDEFINED;
      event1[0].header.source = supplier_id;
      event1[0].header.ttl    = 1;

      RtecEventComm::EventSet event2 (1);
      event2.length (1);
      event2[0].header.type   = ACE_ES_EVENT_UNDEFINED + 1;
      event2[0].header.source = supplier_id;
      event2[0].header.ttl    = 1;

      for (int i = 0; i != 200; ++i)
        {
          if (i % 2 == 0)
            {
              consumer_proxy->push (event1);
            }
          else
            {
              consumer_proxy->push (event2);
            }

          ACE_Time_Value rate (0, 10000);
          ACE_OS::sleep (rate);
        }

      // ****************************************************************

      // We should do a lot of cleanup (disconnect from the EC,
      // deactivate all the objects with the POA, etc.) but this is
      // just a simple demo so we are going to be lazy.

    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Service");
      return 1;
    }
  return 0;
}
Ejemplo n.º 13
0
void UT_CMceStateIdle::UT_CMceStateIdle_EntryLL()
{
//Invite

    CMceComSession* clientSession = CMceComSession::NewL( CMceComSession::EOutSession );
    CleanupStack::PushL( clientSession );
    CMceMsgObject<CMceComSession>* clientSessionMsg =
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );

    TMceIds ids;

    iStorage->iMediaManagerUpdateStatus = KMceAsync;
    TMceStateTransitionEvent event1( *iSipSession, EMceItcEstablishSession, ids,
                                     *clientSessionMsg );

    iState->EntryL( event1 );
    CleanupStack::PopAndDestroy( clientSessionMsg );

    EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::EUpdate );
    EUNIT_ASSERT ( iStorage->iMediaManagerSdpAction == CMCETls::ENone );
    EUNIT_ASSERT ( iSipSession->Body() == clientSession );
    EUNIT_ASSERT ( iSipSession->Body()->iSIPContent == NULL );
    EUNIT_ASSERT ( iSipSession->Offer() == NULL );

    delete iSipSession->iBody;
    iSipSession->iBody = NULL;

    clientSession = CMceComSession::NewL( CMceComSession::EOutSession );
    CleanupStack::PushL( clientSession );
    clientSessionMsg =
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );

    iStorage->iMediaManagerUpdateStatus = KMceReady;
    TMceStateTransitionEvent event1_1( *iSipSession, EMceItcEstablishSession, ids,
                                       *clientSessionMsg );

    iState->EntryL( event1_1 );
    CleanupStack::PopAndDestroy( clientSessionMsg );

    EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::EUpdate );
    EUNIT_ASSERT ( iStorage->iMediaManagerSdpAction == CMCETls::EEncode );
    EUNIT_ASSERT ( iSipSession->Body() == clientSession );
    EUNIT_ASSERT ( iSipSession->Body()->iSIPContent == NULL );
    EUNIT_ASSERT ( iSipSession->Offer() != NULL );


    delete iSipSession->iOffer;
    iSipSession->iOffer = NULL;


//Invited

    iSipSession->Body()->iType = CMceComSession::EInSession;

    RPointerArray<CSIPHeaderBase> sipHeaders;
    CSIPHeaderBase::PushLC( &sipHeaders );

    // Supported: timer
    RStringF timerKey = SIPStrings::Pool().OpenFStringL( KMceSipTimer() );
    CleanupClosePushL( timerKey );

    CSIPSupportedHeader* supportedHeader = CSIPSupportedHeader::NewLC( timerKey );

    User::LeaveIfError( sipHeaders.Append( supportedHeader ) );
    CleanupStack::Pop( supportedHeader );
    CleanupStack::PopAndDestroy();//timerKey

    // Session-Expires: 10

    CSIPExtensionHeader* sessionExpiresHeader =
        CSIPExtensionHeader::NewLC( KSessionExpires(), _L8("10") );
    User::LeaveIfError( sipHeaders.Append( sessionExpiresHeader ) );
    CleanupStack::Pop( sessionExpiresHeader );

    CSIPServerTransaction* srvtransaction =
        MCETestHelper::ServerTransactionL( SipStrConsts::EInvite, sipHeaders, ETrue );
    CleanupStack::PopAndDestroy( &sipHeaders );
    CleanupStack::PushL( srvtransaction );
    iSipSession->iPendingReceivedRequests.AppendL( srvtransaction );
    CleanupStack::Pop( srvtransaction );

    TMceStateTransitionEvent event2( *iSipSession, EMceInvite );
    iState->EntryL( event2 );

    EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::EUpdate );

    iStorage->iMediaManagerAction = CMCETls::ENone;
    iStorage->iMediaManagerDecodeStatus = KMceSipWarnMediaTypeNotAvailable;

    TMceStateTransitionEvent event3( *iSipSession, EMceInvite );
    iState->EntryL( event3 );


    EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::ENone );
    EUNIT_ASSERT ( iStorage->iSipSentResponse->StatusCode() == KMceSipNotAcceptableHere );
    EUNIT_ASSERT ( iSipSession->Body() != NULL );
    EUNIT_ASSERT ( iSipSession->BodyCandidate() == NULL );
    EUNIT_ASSERT ( iSipSession->Body()->iType == CMceComSession::EInSession );
    EUNIT_ASSERT ( iSipSession->Body()->iSIPContent == NULL );


    TMceStateTransitionEvent event4( *iSipSession, EMceCancel );
    iState->EntryL( event4 );

    CSIPServerTransaction& request = iSipSession->Request();
    CSIPRequestElements* requestElement = const_cast<CSIPRequestElements*>(request.RequestElements());
    requestElement->MessageElements().SetContent( NULL );

    TMceStateTransitionEvent event2_2( *iSipSession, EMceInvite );
    iState->EntryL( event2_2 );
}
Ejemplo n.º 14
0
 inline void simulateSymbianCommand(int command)
 {
     QSymbianEvent event1(QSymbianEvent::CommandEvent, command);
     qApp->symbianProcessEvent(&event1);
 };
void UT_CMceStateOffering::UT_CMceStateOffering_ExitLL()
    {
    CMceMsgBase* msg = NULL;
    
    iSipSession->iSubState = CMceSipSession::EOffering;
    
    TMceIds ids;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );

    
    TMceStateTransitionEvent event1( *iSipSession, EMceMediaUpdated );
    iState->ExitL( event1 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateEstablished );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EEstablished );
    

    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );

    TMceStateTransitionEvent event2( *iSipSession, EMceItcCancel, ids, *msg );
    iState->ExitL( event2 );

    //Ringing Case 1: Not Reliable
    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
    
    MCETestHelper::ChangeResponseTypeL( 
        *iSipSession->iResponse->ResponseElements(), 
        KMceSipRinging, 
        SipStrConsts::EPhraseRinging );
    
    TMceStateTransitionEvent event3( *iSipSession, EMceProvisionalResponse );
    iState->ExitL( event3 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EOffering );
    
    
    
	//Ringing Case 2: Reliable Provisional Response
    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
            
    MCETestHelper::SetResponseL( 
        *iSipSession->iResponse, 
        KMceSipRinging, SipStrConsts::EPhraseRinging,
    	EFalse, ETrue, 500);
    
    TMceStateTransitionEvent event3_1( *iSipSession, EMceProvisionalResponse );
    iState->ExitL( event3_1 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EOffering );
    EUNIT_ASSERT ( iSipSession->RSeq() == 500 );
    
        

    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );

    MCETestHelper::ChangeResponseTypeL( 
        *iSipSession->iResponse->ResponseElements(), 
        KMceSipQueued, 
        SipStrConsts::EEmpty );

    TMceStateTransitionEvent event4( *iSipSession, EMceProvisionalResponse );
    iState->ExitL( event4 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EOffering );


    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );

    TMceStateTransitionEvent event5( *iSipSession, EMceErrorResponse );
    iState->ExitL( event5 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateTerminated );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::ETerminated );


    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    iSipSession->Dialog()->Dialog().iState = CSIPDialog::ETerminated;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );

    MCETestHelper::ChangeResponseTypeL( 
        *iSipSession->iResponse->ResponseElements(), 
        KMceSipSessionIntervalTooSmall, 
        SipStrConsts::EPhraseIntervalTooBrief );

    TMceStateTransitionEvent event6( *iSipSession, EMceErrorResponse );
    iState->ExitL( event6 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
      

    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );

    MCETestHelper::ChangeResponseTypeL( 
        *iSipSession->iResponse->ResponseElements(), 
        KMceSipBadRequest, 
        SipStrConsts::EPhraseBadRequest );
    

    TMceStateTransitionEvent event7( *iSipSession, EMceErrorResponse );
    iState->ExitL( event7 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateTerminated );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::ETerminated );

    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EUpdating;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );

    MCETestHelper::ChangeResponseTypeL( 
        *iSipSession->iResponse->ResponseElements(), 
        KMceSipBadRequest, 
        SipStrConsts::EPhraseBadRequest );
    

    TMceStateTransitionEvent event7_1( *iSipSession, EMceErrorResponse );
    iState->ExitL( event7_1 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateEstablished );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EEstablished );


    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EUpdating;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );

    MCETestHelper::ChangeResponseTypeL( 
        *iSipSession->iResponse->ResponseElements(), 
        KMceSipCallOrTransactionDoesNotExist, 
        SipStrConsts::EPhraseCallTransactionDoesNotExist );
    

    TMceStateTransitionEvent event7_2( *iSipSession, EMceErrorResponse );
    iState->ExitL( event7_2 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateTerminating );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::ETerminating );

    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EUpdating;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );

    MCETestHelper::ChangeResponseTypeL( 
        *iSipSession->iResponse->ResponseElements(), 
        KMceSipRequestTimeout, 
        SipStrConsts::EPhraseRequestTimeout );

    TMceStateTransitionEvent event7_3( *iSipSession, EMceErrorResponse );
    iState->ExitL( event7_3 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateTerminating );
    EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::ETerminating );


    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
    
    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    MCETestHelper::ChangeResponseTypeL(
        *iSipSession->iResponse->ResponseElements(),
        KMceSipMovedTemporarily,
        SipStrConsts::EPhraseOk );
    
    TMceStateTransitionEvent event8( *iSipSession, EMceRedirectionResponse );
    iState->ExitL( event8 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
    
    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EUpdating;
    TMceStateTransitionEvent event9( *iSipSession, EMceRedirectionResponse );
    iState->ExitL( event9 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateServerEstablishing );
    
    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EOffering;
    MCETestHelper::ChangeResponseTypeL( 
        *iSipSession->iResponse->ResponseElements(),
        KMceSipMultipleChoices,
        SipStrConsts::EPhraseOk );

    TMceStateTransitionEvent event10( *iSipSession, EMceRedirectionResponse );
    iState->ExitL( event10 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateTerminated );
    
    iSipSession->NextState( KMceStateOffering );
    iSipSession->iSubState = CMceSipSession::EAnswering;
    TMceStateTransitionEvent event11( *iSipSession, EMceRedirectionResponse );
    iState->ExitL( event11 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );   

	// Hanlding of Extension Request / Response does not change the session state    

	//EMceItcReplySend
	TMceStateTransitionEvent event12( *iSipSession, EMceItcReplySend, ids, *msg );
    iState->ExitL( event12 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );   
    
    //EMceRequest
	TMceStateTransitionEvent event13( *iSipSession, EMceRequest );
    iState->ExitL( event13 );
	EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );   
	
	//EMceProvisionalResponse
	CSIPClientTransaction* clitransaction = 
    MCETestHelper::ClientTransactionLC( SipStrConsts::EInfo, KMceSipSessionProgress, 
    									SipStrConsts::EPhraseSessionProgress, ETrue );
	iSipSession->SetPendingTransactionL( clitransaction );
    CleanupStack::Pop( clitransaction );
    iSipSession->iResponse = clitransaction;

	TMceStateTransitionEvent event14( *iSipSession, EMceProvisionalResponse );
    iState->ExitL( event14 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );   

	//EMceResponse
	CSIPClientTransaction* clitransaction1 = 
    MCETestHelper::ClientTransactionLC( SipStrConsts::EInfo, KMceSipOK, 
    									SipStrConsts::EPhraseOk, ETrue );
	iSipSession->SetPendingTransactionL( clitransaction1 );
    CleanupStack::Pop( clitransaction1 );
    iSipSession->iResponse = clitransaction1;
	
	TMceStateTransitionEvent event15( *iSipSession, EMceResponse );
    iState->ExitL( event15 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );   


	//EMceRedirectionResponse
	CSIPClientTransaction* clitransaction2 = 
    MCETestHelper::ClientTransactionLC( SipStrConsts::EInfo, KMceSipMovedTemporarily, 
    									SipStrConsts::EPhraseOk, ETrue );
	iSipSession->SetPendingTransactionL( clitransaction2 );
    CleanupStack::Pop( clitransaction2 );
    iSipSession->iResponse = clitransaction2;
	
	TMceStateTransitionEvent event16( *iSipSession, EMceRedirectionResponse );
    iState->ExitL( event16 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );   
	

	//EMceErrorResponse
	CSIPClientTransaction* clitransaction3 = 
    MCETestHelper::ClientTransactionLC( SipStrConsts::EInfo, KMceSipBadExtension, 
    									SipStrConsts::EPhraseBadExtension, ETrue );
	iSipSession->SetPendingTransactionL( clitransaction3 );
    CleanupStack::Pop( clitransaction3 );
    iSipSession->iResponse = clitransaction3;
	
	TMceStateTransitionEvent event17( *iSipSession, EMceErrorResponse );
    iState->ExitL( event17 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
    
    //EMceMediaUpdated, IMS flow
    TMceStateTransitionEvent event1_1( *iSipSession, EMceMediaUpdated );
    CSIPClientTransaction* response = &iSipSession->Response();
    CSIPCSeqHeader* cSeqHeader = CSIPCSeqHeader::DecodeL( _L8("1 UPDATE") );
    CSIPMessageElements* messageElements =
        const_cast<CSIPMessageElements*>( &response->ResponseElements()->MessageElements() );
    messageElements->AddHeaderL( cSeqHeader );
    iState->ExitL( event1_1 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateOffering );
    }
Ejemplo n.º 16
0
void GLViewImpl::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify)
{
    if(GLFW_MOUSE_BUTTON_LEFT == button)
    {
        if(GLFW_PRESS == action)
        {
            _captured = true;
            if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Vec2(_mouseX,_mouseY)))
            {
                intptr_t id = 0;
                this->handleTouchesBegin(1, &id, &_mouseX, &_mouseY);
            }
        }
        else if(GLFW_RELEASE == action)
        {
            if (_captured)
            {
                _captured = false;
                intptr_t id = 0;
                this->handleTouchesEnd(1, &id, &_mouseX, &_mouseY);
            }
        }
    }
    
    //Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
    float cursorX = (_mouseX - _viewPortRect.origin.x) / _scaleX;
    float cursorY = (_viewPortRect.origin.y + _viewPortRect.size.height - _mouseY) / _scaleY;

    if(GLFW_PRESS == action)
    {
        EventMouse event(EventMouse::MouseEventType::MOUSE_DOWN);
        event.setCursorPosition(cursorX, cursorY);
        event.setMouseButton(button);
		event.setMods(modify);
        Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
    }
    else if(GLFW_RELEASE == action)
    {
        EventMouse event(EventMouse::MouseEventType::MOUSE_UP);
        event.setCursorPosition(cursorX, cursorY);
        event.setMouseButton(button);
		event.setMods(modify);
        Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);

		timeval now;
		long currReleaseTime = 0;
		if (gettimeofday(&now, nullptr) == 0)
			currReleaseTime = now.tv_sec * 1000 + now.tv_usec / 1000;

		if (abs(_mouseX - _lastReleaseMouseX) < 5 && 
			abs(_mouseY - _lastReleaseMouseY) < 5 && 
			(currReleaseTime - _lastReleaseTime) < 300)
		{
			EventMouse event1(EventMouse::MouseEventType::MOUSE_DBLCLK);
			event1.setCursorPosition(cursorX, cursorY);
			event1.setMouseButton(button);
			event1.setMods(modify);
			Director::getInstance()->getEventDispatcher()->dispatchEvent(&event1);
		}
		

		_lastReleaseMouseX = _mouseX;
		_lastReleaseMouseY = _mouseY;
		_lastReleaseTime = currReleaseTime;
    }
}
Ejemplo n.º 17
0
void ComponentEventTest::testConvertSimpleUnits()
{
  std::map<std::string, std::string> attributes;
  attributes["id"] = "1";
  attributes["name"] = "DataItemTest1";
  attributes["type"] = "ACCELERATION";
  attributes["category"] = "SAMPLE";
  
  std::string time("NOW"), value("2.0");
  attributes["nativeUnits"] = "INCH";
  DataItem data1 (attributes);
  ComponentEvent event1 (data1, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 25.4f, event1.getFValue());
  CPPUNIT_ASSERT(event1.getSValue().empty());
  
  attributes["nativeUnits"] = "FOOT";
  DataItem data2 (attributes);
  ComponentEvent event2 (data2, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 304.8f, event2.getFValue());
  CPPUNIT_ASSERT(event2.getSValue().empty());
  
  attributes["nativeUnits"] = "CENTIMETER";
  DataItem data3 (attributes);
  ComponentEvent event3 (data3, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 10.0f, event3.getFValue());
  CPPUNIT_ASSERT(event3.getSValue().empty());
  
  attributes["nativeUnits"] = "DECIMETER";
  DataItem data4 (attributes);
  ComponentEvent event4 (data4, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 100.0f, event4.getFValue());
  CPPUNIT_ASSERT(event4.getSValue().empty());
  
  attributes["nativeUnits"] = "METER";
  DataItem data5 (attributes);
  ComponentEvent event5 (data5, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 1000.0f, event5.getFValue());
  CPPUNIT_ASSERT(event5.getSValue().empty());
  
  attributes["nativeUnits"] = "FAHRENHEIT";
  DataItem data6 (attributes);
  ComponentEvent event6 (data6, 123, "NOW", "2.0");
  CPPUNIT_ASSERT_EQUAL((2.0f - 32.0f) * (5.0f / 9.0f), event6.getFValue());
  CPPUNIT_ASSERT(event6.getSValue().empty());
  
  attributes["nativeUnits"] = "POUND";
  DataItem data7 (attributes);
  ComponentEvent event7 (data7, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 0.45359237f, event7.getFValue());
  CPPUNIT_ASSERT(event7.getSValue().empty());
  
  attributes["nativeUnits"] = "GRAM";
  DataItem data8 (attributes);
  ComponentEvent event8 (data8, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f / 1000.0f, event8.getFValue());
  CPPUNIT_ASSERT(event8.getSValue().empty());
  
  attributes["nativeUnits"] = "RADIAN";
  DataItem data9 (attributes);
  ComponentEvent event9 (data9, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 57.2957795f, event9.getFValue());
  CPPUNIT_ASSERT(event9.getSValue().empty());
  
  attributes["nativeUnits"] = "MINUTE";
  DataItem data10 (attributes);
  ComponentEvent event10 (data10, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 60.0f, event10.getFValue());
  CPPUNIT_ASSERT(event10.getSValue().empty());
  
  attributes["nativeUnits"] = "HOUR";
  DataItem data11 (attributes);
  ComponentEvent event11 (data11, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f * 3600.0f, event11.getFValue());
  CPPUNIT_ASSERT(event11.getSValue().empty());
  
  attributes["nativeUnits"] = "MILLIMETER";
  DataItem data12 (attributes);
  ComponentEvent event12 (data12, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f, event12.getFValue());
  CPPUNIT_ASSERT(event12.getSValue().empty());
  
  attributes["nativeUnits"] = "PERCENT";
  DataItem data13 (attributes);
  ComponentEvent event13 (data13, 123, time, value);
  CPPUNIT_ASSERT_EQUAL(2.0f, event13.getFValue());
  CPPUNIT_ASSERT(event13.getSValue().empty());
}
void UT_CMceStateServerEstablishing::UT_CMceStateServerEstablishing_EntryLL()
    {
    
    CSIPServerTransaction* invite = 
            MCETestHelper::ServerTransactionL( SipStrConsts::EInvite );
    CleanupStack::PushL( invite );
    iSipSession->iPendingReceivedRequests.AppendL( invite );
    CleanupStack::Pop( invite );
    
    TMceIds ids;
    CMceMsgBase* msg = NULL;
    
    iSipSession->iBody = CMceComSession::NewL( CMceComSession::EInSession );
    iSipSession->iBody->iID = 1;
    iSipSession->iNewBodyCandidate = CMceComSession::NewL( CMceComSession::EInSession );
    iSipSession->iNewBodyCandidate->iID = 1;
    
    ids.iAppUID = 10;
    ids.iSessionID = 1;
    
    CMceComSession* clientSession = CMceComSession::NewL( CMceComSession::EInSession );
    clientSession->iID = 1;
    ids.iSessionID = clientSession->iID;
    CleanupStack::PushL( clientSession );
    CMceMsgObject<CMceComSession>* clientSessionMsg = 
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );
    

    iSipSession->iSubState = CMceSipSession::EAnswering;
    MCE_RESET_STUBS();
    iStorage->iMediaManagerUpdateStatus = KMceAsync;
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;
    
    TMceStateTransitionEvent event1( *iSipSession, EMceItcUpdate, ids, 
                                      *clientSessionMsg );

    iState->EntryL( event1 );
    MCE_ENTRYL_POSTCONDITION
    
    MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
                      CMCETls::ENone /*mmsdpaction*/, 
                      SipStrConsts::EEmpty /*sentMethod*/, 
                      KErrNotFound /*sentResponse*/);
    
    EUNIT_ASSERT ( event1.Code() == EMceItcUpdate );
    EUNIT_ASSERT ( event1.ParamStatus() == KMceAsync );
    MCE_RESET_STUBS();
    CleanupStack::PopAndDestroy( clientSessionMsg );

// ---

    clientSession = CMceComSession::NewL( CMceComSession::EInSession );
    clientSession->iID = 1;
    ids.iSessionID = clientSession->iID;
    CleanupStack::PushL( clientSession );
    clientSessionMsg = 
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );


    iSipSession->iSubState = CMceSipSession::EAnswering;
    iStorage->iMediaManagerUpdateStatus = KErrGeneral;
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;
    
    TMceStateTransitionEvent event2( *iSipSession, EMceItcUpdate, ids, 
                                      *clientSessionMsg );

    iState->EntryL( event2 );
    MCE_ENTRYL_POSTCONDITION_2( KMceSipServerInternalError )
    
    MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
                      CMCETls::ENone /*mmsdpaction*/, 
                      SipStrConsts::EEmpty /*sentMethod*/, 
                      KMceSipServerInternalError /*sentResponse*/);
    
    EUNIT_ASSERT ( event2.Code() == EMceItcRejectSession );
    EUNIT_ASSERT ( event2.ParamStatus() == KErrGeneral );
    MCE_RESET_STUBS();
    CleanupStack::PopAndDestroy( clientSessionMsg );

// ---

    clientSession = CMceComSession::NewL( CMceComSession::EInSession );
    clientSession->iID = 1000;//wrong
    ids.iSessionID = clientSession->iID;
    CleanupStack::PushL( clientSession );
    clientSessionMsg = 
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );


    iSipSession->iSubState = CMceSipSession::EAnswering;
    iStorage->iMediaManagerUpdateStatus = KMceAsync;
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;
    
    TMceStateTransitionEvent event2_1( *iSipSession, EMceItcUpdate, ids, 
                                      *clientSessionMsg );

    MCE_EUNIT_ASSERT_LEAVE( iState->EntryL( event2_1 ) );
    
    MCE_RESET_STUBS();
    CleanupStack::PopAndDestroy( clientSessionMsg );


// ---

    clientSession = CMceComSession::NewL( CMceComSession::EInSession );
    clientSession->iID = 1;
    ids.iSessionID = clientSession->iID;
    CleanupStack::PushL( clientSession );
    clientSessionMsg = 
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );

    iSipSession->iSubState = CMceSipSession::EUpdating;
    iStorage->iMediaManagerUpdateStatus = KMceAsync;
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;
    
    TMceStateTransitionEvent event3( *iSipSession, EMceItcUpdate, ids, 
                                      *clientSessionMsg );

    iState->EntryL( event3 );
    MCE_ENTRYL_POSTCONDITION
    
    MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
                      CMCETls::ENone /*mmsdpaction*/, 
                      SipStrConsts::EEmpty /*sentMethod*/, 
                      KErrNotFound /*sentResponse*/);
    
    EUNIT_ASSERT ( iStorage->iSipSentResponse == NULL );
    EUNIT_ASSERT ( event3.Code() == EMceItcUpdate );
    EUNIT_ASSERT ( event3.ParamStatus() == KMceAsync );
    MCE_RESET_STUBS();
    CleanupStack::PopAndDestroy( clientSessionMsg );

// ---
    // EMceItcUpdate, update ready, directly 200
    clientSession = CMceComSession::NewL( CMceComSession::EInSession );
    clientSession->iID = 1;
    ids.iSessionID = clientSession->iID;
    CleanupStack::PushL( clientSession );
    clientSessionMsg = 
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );

    iSipSession->iSubState = CMceSipSession::EUpdating;
    iStorage->iMediaManagerUpdateStatus = KMceReady;
    iStorage->iMediaManagerNeedToNegotiate = EFalse;
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;
    
    TMceStateTransitionEvent event4( *iSipSession, EMceItcUpdate, ids, 
                                      *clientSessionMsg );

    iState->EntryL( event4 );
    MCE_ENTRYL_POSTCONDITION_2( KMceSipOK )
    MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
                      CMCETls::EEncode /*mmsdpaction*/, 
                      SipStrConsts::EEmpty /*sentMethod*/, 
                      KMceSipOK /*sentResponse*/);
    
    EUNIT_ASSERT ( event4.Code() == EMceItcUpdate );
    EUNIT_ASSERT ( event4.ParamStatus() == KMceReady );
    EUNIT_ASSERT ( iSipSession->BodyCandidate() == NULL );
    MCE_RESET_STUBS();
    CleanupStack::PopAndDestroy( clientSessionMsg );

    iSipSession->iNewBodyCandidate = CMceComSession::NewL( CMceComSession::EInSession );
    iSipSession->iNewBodyCandidate->iID = 1;

// ---
    // EMceItcUpdate, update ready, need 183
    clientSession = CMceComSession::NewL( CMceComSession::EInSession );
    clientSession->iID = 1;
    ids.iSessionID = clientSession->iID;
    CleanupStack::PushL( clientSession );
    clientSessionMsg = 
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );

    iSipSession->iSubState = CMceSipSession::EUpdating;
    iStorage->iMediaManagerUpdateStatus = KMceReady;
    iStorage->iMediaManagerNeedToNegotiate = ETrue;
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;
    iSipSession->Extensions().SetRemote( CMceSipExtensions::E100rel, CMceSipExtensions::ESupported );
    TMceStateTransitionEvent event4_2( *iSipSession, EMceItcUpdate, ids, 
                                      *clientSessionMsg );

    iState->EntryL( event4_2 );
    MCE_ENTRYL_POSTCONDITION_2( KMceSipSessionProgress )
    MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
                      CMCETls::EEncode /*mmsdpaction*/, 
                      SipStrConsts::EEmpty /*sentMethod*/, 
                      KMceSipSessionProgress /*sentResponse*/);
    
    EUNIT_ASSERT ( event4_2.Code() == EMceItcUpdate );
    EUNIT_ASSERT ( event4_2.ParamStatus() == KMceReady );
    EUNIT_ASSERT ( iSipSession->BodyCandidate() != NULL );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateAcknowledgementRequired );
    
    MCE_RESET_STUBS();
    CleanupStack::PopAndDestroy( clientSessionMsg );
    MCE_DELETE( iSipSession->iNewBodyCandidate );
    iSipSession->iNewBodyCandidate = CMceComSession::NewL( CMceComSession::EInSession );
    iSipSession->iNewBodyCandidate->iID = 1;

// ---

    clientSession = CMceComSession::NewL( CMceComSession::EInSession );
    clientSession->iID = 1;
    ids.iSessionID = clientSession->iID;
    CleanupStack::PushL( clientSession );
    clientSessionMsg = 
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );

    iSipSession->iSubState = CMceSipSession::EUpdating;
    iStorage->iMediaManagerUpdateStatus = KErrGeneral;
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;
    
    TMceStateTransitionEvent event5( *iSipSession, EMceItcUpdate, ids, 
                                      *clientSessionMsg );

    iState->EntryL( event5 );
    MCE_ENTRYL_POSTCONDITION_2( KMceSipServerInternalError )
    MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
                      CMCETls::ENone /*mmsdpaction*/, 
                      SipStrConsts::EEmpty /*sentMethod*/, 
                      KMceSipServerInternalError /*sentResponse*/);
    
    EUNIT_ASSERT ( event5.Code() == EMceItcUpdate );
    EUNIT_ASSERT ( event5.ParamStatus() == KErrGeneral );
    EUNIT_ASSERT ( iSipSession->BodyCandidate() == NULL );
    MCE_RESET_STUBS();
    CleanupStack::PopAndDestroy( clientSessionMsg );
    
    iSipSession->iNewBodyCandidate = CMceComSession::NewL( CMceComSession::EInSession );
    iSipSession->iNewBodyCandidate->iID = 1;
    

// ---

    clientSession = CMceComSession::NewL( CMceComSession::EInSession );
    clientSession->iID = 1000;//wrong
    ids.iSessionID = clientSession->iID;
    CleanupStack::PushL( clientSession );
    clientSessionMsg = 
        new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
    CleanupStack::Pop( clientSession );
    clientSessionMsg->PushL();
    CleanupStack::PushL( clientSessionMsg );

    iSipSession->iSubState = CMceSipSession::EUpdating;
    iStorage->iMediaManagerUpdateStatus = KMceAsync;
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;
    
    TMceStateTransitionEvent event5_1( *iSipSession, EMceItcUpdate, ids, 
                                      *clientSessionMsg );

    MCE_EUNIT_ASSERT_LEAVE( iState->EntryL( event5_1 ) );
    
    MCE_RESET_STUBS();
    CleanupStack::PopAndDestroy( clientSessionMsg );


// --- reject

    iSipSession->iSubState = CMceSipSession::EOffering;
    iStorage->iMediaManagerAction = CMCETls::ENone;
    iStorage->iSipSentMethod = SIPStrings::StringF( SipStrConsts::EEmpty );
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;

    TMceStateTransitionEvent event6( *iSipSession, EMceItcRejectSession, ids );

    iState->EntryL( event6 );
    MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
                      CMCETls::ENone /*mmsdpaction*/, 
                      SipStrConsts::EEmpty /*sentMethod*/, 
                      KMceSipDecline /*sentResponse*/);
    
    EUNIT_ASSERT ( event6.Code() == EMceItcRejectSession );
    EUNIT_ASSERT ( event6.ParamStatus() == KErrNone );
    MCE_RESET_STUBS();
    
// --- reject

    iSipSession->iSubState = CMceSipSession::EUpdating;
    iStorage->iMediaManagerAction = CMCETls::ENone;
    iStorage->iSipSentMethod = SIPStrings::StringF( SipStrConsts::EEmpty );
    delete iStorage->iSipSentResponse;
    iStorage->iSipSentResponse = NULL;

    TMceStateTransitionEvent event7( *iSipSession, EMceItcRejectSession, ids );

    iState->EntryL( event7 );
    
    MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
                      CMCETls::ENone /*mmsdpaction*/, 
                      SipStrConsts::EEmpty /*sentMethod*/, 
                      KMceSipDecline /*sentResponse*/);
    
    EUNIT_ASSERT ( event7.Code() == EMceItcRejectSession );
    EUNIT_ASSERT ( event7.ParamStatus() == KErrNone );


// --- default

    TMceStateTransitionEvent event8( *iSipSession, EMceItcRing, ids );

    iState->EntryL( event8 );
    
    MCE_RESET_STUBS();
    
                      
// ---  Enable & disable    
    
    MCE_ASSERT_ENDPOINT_ENABLE_AND_DISABLE();
    
    }
void UT_CMceStateOffering::UT_CMceStateOffering_AcceptLL()
    {
    TMceIds ids;
    CMceMsgBase* msg = NULL;

    TMceStateTransitionEvent event0( *iSipSession, EMceUpdate );
    EUNIT_ASSERT ( iState->AcceptL( event0 ) );

    TMceStateTransitionEvent event1( *iSipSession, EMceItcCancel, ids, *msg );
    EUNIT_ASSERT ( iState->AcceptL( event1 ) );

    TMceStateTransitionEvent event2( *iSipSession, EMceResponse );
    EUNIT_ASSERT ( iState->AcceptL( event2 ) );

    TMceStateTransitionEvent event3( *iSipSession, EMceProvisionalResponse );
    EUNIT_ASSERT ( iState->AcceptL( event3 ) );
    
    TMceStateTransitionEvent event4( *iSipSession, EMceErrorResponse );
    EUNIT_ASSERT ( iState->AcceptL( event4 ) );

    TMceStateTransitionEvent event5( *iSipSession, EMceMediaUpdated );
    EUNIT_ASSERT ( iState->AcceptL( event5 ) );

    TMceStateTransitionEvent event6( *iSipSession, EMceRedirectionResponse );
    EUNIT_ASSERT ( iState->AcceptL( event6 ) );
    
    TMceStateTransitionEvent event7( *iSipSession, EMceMediaSessionStopped );
    TRAPD( e1, iState->AcceptL( event7 ) );
    EUNIT_ASSERT ( e1 == KErrTotalLossOfPrecision );

	// Following Events will be accepted for Extenssion Requests
    CSIPClientTransaction* clitransaction2 = 
    MCETestHelper::ClientTransactionLC( SipStrConsts::EInfo, KMceSipSessionProgress, 
    									SipStrConsts::EPhraseSessionProgress, ETrue );
	iSipSession->SetPendingTransactionL( clitransaction2 );
    CleanupStack::Pop( clitransaction2 );
    iSipSession->iResponse = clitransaction2;

    TMceStateTransitionEvent event2a( *iSipSession, EMceResponse );
	TRAPD( e2a, iState->AcceptL( event2a ) );
    EUNIT_ASSERT ( e2a == KErrNone );

    TMceStateTransitionEvent event2b( *iSipSession, EMceProvisionalResponse );
	TRAPD( e2b, iState->AcceptL( event2b ) );
    EUNIT_ASSERT ( e2b == KErrNone );

    TMceStateTransitionEvent event2c( *iSipSession, EMceRedirectionResponse );
	TRAPD( e2c, iState->AcceptL( event2c ) );
	EUNIT_ASSERT ( e2c == KErrNone );

	TMceStateTransitionEvent event2d( *iSipSession, EMceErrorResponse );
	TRAPD( e2d, iState->AcceptL( event2d ) );
	EUNIT_ASSERT ( e2d == KErrNone );
	
	TMceStateTransitionEvent event2e( *iSipSession, EMceItcReplySend, ids, *msg );
	TRAPD( e2e, iState->AcceptL( event2e ) );
	EUNIT_ASSERT ( e2e == KErrNone );
	
	TMceStateTransitionEvent event2f( *iSipSession, EMceRequest );
	TRAPD( e2f, iState->AcceptL( event2f ) );
	EUNIT_ASSERT ( e2f == KErrNone );
    }
void UT_CMceStateOffering::UT_CMceStateOffering_EntryL_With2XXResponsesL()
    {
    TMceIds ids;
    CMceMsgBase* msg = NULL;

    // 200 OK with answer decoding ready
    MCE_RESET_STUBS();
    iStorage->iMediaManagerUpdateStatus = KMceReady;
    iSipSession->iSubState = CMceSipSession::EOffering;
    CMceComSession& body = iSipSession->ActiveBody();
    body.iSdpSession = iSdpSession;
    body.SecureSessionL();
    
    TMceStateTransitionEvent event1( *iSipSession, EMceResponse );
    iState->EntryL( event1 );
    MCE_ENTRYL_POSTCONDITION
    
    MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
                      CMCETls::EDecode /*mmsdpaction*/, 
                      SipStrConsts::EAck /*sentMethod*/, 
                      KErrNotFound /*sentResponse*/);
    
    EUNIT_ASSERT ( iStorage->iAckSent );
    EUNIT_ASSERT ( event1.Code() == EMceMediaUpdated );
    EUNIT_ASSERT ( iSipSession->PendingTransactions().Count() == 1 );
    EUNIT_ASSERT ( !iSipSession->WaitingMediaCallback() );
	EUNIT_ASSERT ( body.iSipContactAddrSecure == CMceSession::EControlPathUnsecure );
	EUNIT_ASSERT ( body.SecureSession()->iLSReadyToBind == ETrue );

    iSipSession->iSubState = CMceSipSession::EOffering;
    MCE_RESET_STUBS();
   
    // 200 OK with answer decoding not ready
    iSipSession->iSubState = CMceSipSession::EOffering;
    iStorage->iMediaManagerUpdateStatus = KMceAsync;
    
    TMceStateTransitionEvent event2( *iSipSession, EMceResponse );
    iState->EntryL( event2 );
    MCE_ENTRYL_POSTCONDITION
    
    MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
                      CMCETls::EDecode /*mmsdpaction*/, 
                      SipStrConsts::EAck /*sentMethod*/, 
                      KErrNotFound /*sentResponse*/);
    
    EUNIT_ASSERT ( iStorage->iAckSent );
    EUNIT_ASSERT ( event2.Code() == EMceResponse );
    EUNIT_ASSERT ( iSipSession->PendingTransactions().Count() == 1 );
    EUNIT_ASSERT ( iSipSession->WaitingMediaCallback() );
    MCE_RESET_STUBS();
    
    // 200 OK while waiting for media callback
    iSipSession->iSubState = CMceSipSession::EOffering;
    iStorage->iMediaManagerUpdateStatus = KMceAsync;
    
    TMceStateTransitionEvent event2_1( *iSipSession, EMceResponse );
    iState->EntryL( event2_1 );
    MCE_ENTRYL_POSTCONDITION
    
    MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
                      CMCETls::ENone /*mmsdpaction*/, 
                      SipStrConsts::EAck /*sentMethod*/, 
                      KErrNotFound /*sentResponse*/);
    
    EUNIT_ASSERT ( iStorage->iAckSent );
    EUNIT_ASSERT ( event2_1.Code() == EMceResponse );
    EUNIT_ASSERT ( iSipSession->PendingTransactions().Count() == 1 );
    EUNIT_ASSERT ( iSipSession->WaitingMediaCallback() );
    MCE_RESET_STUBS();
    
    // 200 OK with wrong SDP
    iSipSession->iSubState = CMceSipSession::EOffering;
    iSipSession->SetWaitingMediaCallback( EFalse );
    iStorage->iMediaManagerUpdateStatus = KErrGeneral;
    
    iSipSession->NextState( KMceStateOffering );
    //use handlesipevent
    iSipSession->HandleSIPEvent( EMceResponse, iSipSession->Dialog()->Dialog() );
    MCE_CHECK_MEMORY_LEAVE( iStorage->iMediaManagerSdpAction != CMCETls::EDecode || 
         iStorage->iSipSentMethod != SIPStrings::StringF( SipStrConsts::EBye ) )
    MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
                      CMCETls::EDecode /*mmsdpaction*/, 
                      SipStrConsts::EBye /*sentMethod*/, 
                      KErrNotFound /*sentResponse*/);
    
    EUNIT_ASSERT ( iStorage->iAckSent );
    EUNIT_ASSERT ( iSipSession->PendingTransactions().Count() == 2 );
    EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateTerminating );
    MCE_RESET_STUBS();
    }
Ejemplo n.º 21
0
void wxTextCtrl::OnChar(wxKeyEvent& event)
{
    int key = event.GetKeyCode() ;
    bool eat_key = false ;
    long from, to;

    if ( !IsEditable() && !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB) &&
        !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
//        && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
        )
    {
        // eat it
        return ;
    }

    if ( !GetTextPeer()->CanClipMaxLength() )
    {
        // Check if we have reached the max # of chars (if it is set), but still
        // allow navigation and deletion
        GetSelection( &from, &to );
        if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength &&
            !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB | WXK_CATEGORY_CUT) &&
            !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) &&
            from == to )
        {
            // eat it, we don't want to add more than allowed # of characters

            // TODO: generate EVT_TEXT_MAXLEN()
            return;
        }
    }

    // assume that any key not processed yet is going to modify the control
    m_dirty = true;

    switch ( key )
    {
        case WXK_RETURN:
            if (m_windowStyle & wxTE_PROCESS_ENTER)
            {
                wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId);
                event.SetEventObject( this );
                event.SetString( GetValue() );
                if ( HandleWindowEvent(event) )
                    return;
            }

            if ( !(m_windowStyle & wxTE_MULTILINE) )
            {
                wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
                if ( tlw && tlw->GetDefaultItem() )
                {
                    wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
                    if ( def && def->IsEnabled() )
                    {
                        wxCommandEvent event(wxEVT_BUTTON, def->GetId() );
                        event.SetEventObject(def);
                        def->Command(event);

                        return ;
                    }
                }

                // this will make wxWidgets eat the ENTER key so that
                // we actually prevent line wrapping in a single line text control
                eat_key = true;
            }
            break;

        case WXK_TAB:
            if ( !(m_windowStyle & wxTE_PROCESS_TAB))
            {
                int flags = 0;
                if (!event.ShiftDown())
                    flags |= wxNavigationKeyEvent::IsForward ;
                if (event.ControlDown())
                    flags |= wxNavigationKeyEvent::WinChange ;
                Navigate(flags);

                return;
            }
            else
            {
                // This is necessary (don't know why);
                // otherwise the tab will not be inserted.
                WriteText(wxT("\t"));
                eat_key = true;
            }
            break;

        default:
            break;
    }

    if (!eat_key)
    {
        // perform keystroke handling
        event.Skip(true) ;
    }

    // osx_cocoa sends its event upon insertText
#if wxOSX_USE_CARBON
    if ( ( key >= 0x20 && key < WXK_START ) ||
         ( key >= WXK_NUMPAD0 && key <= WXK_DIVIDE ) ||
         key == WXK_RETURN ||
         key == WXK_DELETE ||
         key == WXK_BACK)
    {
        wxCommandEvent event1(wxEVT_TEXT, m_windowId);
        event1.SetEventObject( this );
        wxPostEvent( GetEventHandler(), event1 );
    }
#endif
}
Ejemplo n.º 22
0
int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Bug_3541_Regression_Test"));

  int ret = 0;

#if defined(ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION)
  int lastError;

  // ACE_OS::event_init()

  const ACE_TCHAR *eventName = ACE_TEXT ("Bug3541_Event");

  ACE_Event event0(0,             // int manual_reset = 0
                   0,             // int initial_state = 0
                   USYNC_PROCESS, // int type = USYNC_THREAD
                   eventName);    // const ACE_TCHAR *name = 0

  lastError = ACE_OS::last_error();

  ACE_event_t eventHandle = event0.handle();

  if ((eventHandle == ACE_INVALID_HANDLE) ||
      (lastError != 0))
  {
    ret = -1;

    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("ACE_Event(%s) failed - handle %d lastError %d\n"),
                eventName, eventHandle, lastError));
  }
  else
  {
    ACE_Event event1(0,              // int manual_reset = 0
                     0,              // int initial_state = 0
                     USYNC_PROCESS,  // int type = USYNC_THREAD
                     eventName);     // const ACE_TCHAR *name = 0

    lastError = ACE_OS::last_error();

    eventHandle = event1.handle();

    if ((eventHandle == ACE_INVALID_HANDLE) ||
        (lastError != ERROR_ALREADY_EXISTS))
    {
      ret = -1;

      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("ACE_Event(%s) failed - handle %d lastError %d\n"),
                  eventName, eventHandle, lastError));
    }
  }

  // ACE_OS::sema_init

  const ACE_TCHAR *semaphoreName = ACE_TEXT ("Bug3541_Semaphore");

  ACE_Semaphore semaphore0(1,               // int count = 1
                           USYNC_PROCESS,   // int type = USYNC_THREAD
                           semaphoreName);  // const ACE_TCHAR *name = 0

  lastError = ACE_OS::last_error();

  const ACE_sema_t &semaphoreLock = semaphore0.lock();
  if ((semaphoreLock == ACE_INVALID_HANDLE) ||
      (lastError != 0))
  {
    ret = -1;

    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("ACE_Semaphore(%s) failed - lock %d lastError %d\n"),
                semaphoreName, semaphoreLock, lastError));
  }
  else
  {
    ACE_Semaphore semaphore1(1,               // int count = 1
                             USYNC_PROCESS,   // int type = USYNC_THREAD
                             semaphoreName);  // const ACE_TCHAR *name = 0

    lastError = ACE_OS::last_error();

    const ACE_sema_t &semaphoreLock = semaphore1.lock();

    if ((semaphoreLock == ACE_INVALID_HANDLE) ||
        (lastError != ERROR_ALREADY_EXISTS))
    {
      ret = -1;

      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("ACE_Semaphore(%s) failed - lock %d lastError %d\n"),
                  semaphoreName, semaphoreLock, lastError));
    }
  }

  // ACE_OS::mutex_init()

  const ACE_TCHAR *mutexName = ACE_TEXT ("Bug3541_Mutex");

  ACE_Mutex mutex0(USYNC_PROCESS,  // int type = USYNC_THREAD
                   mutexName);     // const ACE_TCHAR *name = 0

  lastError = ACE_OS::last_error();

  const ACE_mutex_t &mutexLock = mutex0.lock();

  if ((mutexLock.proc_mutex_ == ACE_INVALID_HANDLE) ||
      (lastError != 0))
  {
    ret = -1;

    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("ACE_Mutex(%s) failed - lock %d lastError %d\n"),
                mutexName, mutexLock, lastError));
  }
  else
  {
    ACE_Mutex mutex1(USYNC_PROCESS,  // int type = USYNC_THREAD
                     mutexName);     // const ACE_TCHAR *name = 0

    lastError = ACE_OS::last_error();

    const ACE_mutex_t &mutexLock = mutex1.lock();

    if ((mutexLock.proc_mutex_ == ACE_INVALID_HANDLE) ||
        (lastError != ERROR_ALREADY_EXISTS))
    {
      ret = -1;

      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("ACE_Mutex(%s) failed - lock %d lastError %d\n"),
                  mutexName, mutexLock, lastError));
    }
  }

 #endif

  ACE_END_TEST;

  return ret;
}