TEST(OriginAccessEntryTest, IPAddressMatchingTest) { struct TestCase { const char* protocol; const char* host; const char* origin; OriginAccessEntry::MatchResult expected; } inputs[] = { { "http", "192.0.0.123", "http://192.0.0.123/", OriginAccessEntry::MatchesOrigin }, { "http", "0.0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatchOrigin }, { "http", "0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatchOrigin }, { "http", "1.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatchOrigin }, }; OriginAccessEntryTestPlatform platform; platform.setPublicSuffix("com"); Platform::initialize(&platform); for (const auto& test : inputs) { SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: " << test.origin); RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(test.origin); OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::AllowSubdomains); EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); OriginAccessEntry entry2(test.protocol, test.host, OriginAccessEntry::DisallowSubdomains); EXPECT_EQ(test.expected, entry2.matchesOrigin(*originToTest)); } Platform::shutdown(); }
void tst_QFileSystemEntry::getSetCheck() { QFETCH(QByteArray, nativeFilePath); QFETCH(QString, filepath); QFETCH(QString, filename); QFETCH(QString, basename); QFETCH(QString, completeBasename); QFETCH(QString, suffix); QFETCH(QString, completeSuffix); QFETCH(bool, absolute); QFileSystemEntry entry1(filepath); QCOMPARE(entry1.filePath(), filepath); QCOMPARE(entry1.nativeFilePath(), nativeFilePath); QCOMPARE(entry1.fileName(), filename); QCOMPARE(entry1.suffix(), suffix); QCOMPARE(entry1.completeSuffix(), completeSuffix); QCOMPARE(entry1.isAbsolute(), absolute); QCOMPARE(entry1.isRelative(), !absolute); QCOMPARE(entry1.baseName(), basename); QCOMPARE(entry1.completeBaseName(), completeBasename); QFileSystemEntry entry2(nativeFilePath, QFileSystemEntry::FromNativePath()); QCOMPARE(entry2.suffix(), suffix); QCOMPARE(entry2.completeSuffix(), completeSuffix); QCOMPARE(entry2.isAbsolute(), absolute); QCOMPARE(entry2.isRelative(), !absolute); QCOMPARE(entry2.filePath(), filepath); QCOMPARE(entry2.nativeFilePath(), nativeFilePath); QCOMPARE(entry2.fileName(), filename); QCOMPARE(entry2.baseName(), basename); QCOMPARE(entry2.completeBaseName(), completeBasename); }
void entry_( void *ptr, int *size ) { fds * myfds = ptr; myinttype *f1 = myfds->feld1, *f2 = myfds->feld2, *f3 = myfds->feld3; if ( *size == 0 ) return ; else entry1( f1, f2, f3, size ); }
//*********************************************************************************** static CSchEntryInfoArray* CreateScheduleArrayLC() { CSchEntryInfoArray* entryList = new (ELeave) CSchEntryInfoArray(3); CleanupStack::PushL(entryList); TTime ttime(SchSvrHelpers::TimeBasedOnOffset(0, 20)); TTsTime startTime (ttime,ETrue); TScheduleEntryInfo2 entry1 (startTime, EDaily, 1, 20); // 20m from "now" entryList->AppendL(entry1); return entryList; }
static gint gtk_listbox_sort_callback(GtkTreeModel * WXUNUSED(model), GtkTreeIter *a, GtkTreeIter *b, wxListBox *listbox) { wxGtkObject<GtkTreeEntry> entry1(GetEntry(listbox->m_liststore, a, listbox)); wxCHECK_MSG(entry1, 0, wxT("Could not get first entry")); wxGtkObject<GtkTreeEntry> entry2(GetEntry(listbox->m_liststore, b, listbox)); wxCHECK_MSG(entry2, 0, wxT("Could not get second entry")); //We compare collate keys here instead of calling g_utf8_collate //as it is rather slow (and even the docs recommend this) return strcmp(gtk_tree_entry_get_collate_key(entry1), gtk_tree_entry_get_collate_key(entry2)) >= 0; }
TEST(OriginAccessEntryTest, PublicSuffixListTest) { OriginAccessEntryTestPlatform platform; platform.setPublicSuffix("com"); Platform::initialize(&platform); RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString("http://www.google.com"); OriginAccessEntry entry1("http", "google.com", OriginAccessEntry::AllowSubdomains); OriginAccessEntry entry2("http", "hamster.com", OriginAccessEntry::AllowSubdomains); OriginAccessEntry entry3("http", "com", OriginAccessEntry::AllowSubdomains); EXPECT_EQ(OriginAccessEntry::MatchesOrigin, entry1.matchesOrigin(*origin)); EXPECT_EQ(OriginAccessEntry::DoesNotMatchOrigin, entry2.matchesOrigin(*origin)); EXPECT_EQ(OriginAccessEntry::MatchesOriginButIsPublicSuffix, entry3.matchesOrigin(*origin)); Platform::shutdown(); }
LOCAL_C void DoStartL() { CCommandLineArguments* args = CCommandLineArguments::NewLC(); TInt i = args->Count(); if ( args->Count() == 2 ) { TLex tlex(args->Arg(1)); TInt argVal = 0; if ( tlex.Val(argVal) == KErrNone ) { // if(argVal == 1) { RFeatureControl control; TInt err = control.Connect(); TBitFlags32 flags( 0 ); flags.Set( EFeatureSupported); flags.Set( EFeatureModifiable ); // Adding features TFeatureEntry entry1( KNewUid1, flags, KDefaultData1 ); err = control.AddFeature(entry1); control.Close(); } else if( argVal == 2) { RFeatureControl control; TInt err = control.Connect(); err = control.SWIEnd(); control.Close(); } } } CleanupStack::PopAndDestroy(); //args }
TEST(OriginAccessEntryTest, AllowRegisterableDomainsTestWithDottedSuffix) { struct TestCase { const char* protocol; const char* host; const char* origin; OriginAccessEntry::MatchResult expected; } inputs[] = { { "http", "example.appspot.com", "http://example.appspot.com/", OriginAccessEntry::MatchesOrigin }, { "http", "example.appspot.com", "http://www.example.appspot.com/", OriginAccessEntry::MatchesOrigin }, { "http", "example.appspot.com", "http://www.www.example.appspot.com/", OriginAccessEntry::MatchesOrigin }, { "http", "www.example.appspot.com", "http://example.appspot.com/", OriginAccessEntry::MatchesOrigin }, { "http", "www.example.appspot.com", "http://www.example.appspot.com/", OriginAccessEntry::MatchesOrigin }, { "http", "www.example.appspot.com", "http://www.www.example.appspot.com/", OriginAccessEntry::MatchesOrigin }, { "http", "appspot.com", "http://example.appspot.com/", OriginAccessEntry::MatchesOriginButIsPublicSuffix }, { "http", "appspot.com", "http://www.example.appspot.com/", OriginAccessEntry::MatchesOriginButIsPublicSuffix }, { "http", "appspot.com", "http://www.www.example.appspot.com/", OriginAccessEntry::MatchesOriginButIsPublicSuffix }, { "https", "example.appspot.com", "http://example.appspot.com/", OriginAccessEntry::DoesNotMatchOrigin }, { "https", "example.appspot.com", "http://www.example.appspot.com/", OriginAccessEntry::DoesNotMatchOrigin }, { "https", "example.appspot.com", "http://www.www.example.appspot.com/", OriginAccessEntry::DoesNotMatchOrigin }, { "http", "example.appspot.com", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOrigin }, { "http", "", "http://example.appspot.com/", OriginAccessEntry::MatchesOrigin }, { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOrigin }, }; OriginAccessEntryTestPlatform platform; platform.setPublicSuffix("appspot.com"); Platform::initialize(&platform); for (const auto& test : inputs) { RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(test.origin); OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::AllowRegisterableDomains); SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: " << test.origin << ", Domain: " << entry1.registerable().utf8().data()); EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); } Platform::shutdown(); }
void tst_QFileSystemEntry::getSetCheck() { QFETCH(QString, nativeFilePath); QFETCH(QString, internalnativeFilePath); QFETCH(QString, filepath); QFETCH(QString, filename); QFETCH(QString, baseName); QFETCH(QString, completeBasename); QFETCH(QString, suffix); QFETCH(QString, completeSuffix); QFETCH(bool, absolute); QFETCH(bool, relative); QFileSystemEntry entry1(filepath); QCOMPARE(entry1.filePath(), filepath); QCOMPARE(entry1.nativeFilePath().toLower(), internalnativeFilePath.toLower()); QCOMPARE(entry1.fileName(), filename); QCOMPARE(entry1.suffix(), suffix); QCOMPARE(entry1.completeSuffix(), completeSuffix); QCOMPARE(entry1.isAbsolute(), absolute); QCOMPARE(entry1.isRelative(), relative); QCOMPARE(entry1.baseName(), baseName); QCOMPARE(entry1.completeBaseName(), completeBasename); QFileSystemEntry entry2(nativeFilePath, QFileSystemEntry::FromNativePath()); QCOMPARE(entry2.suffix(), suffix); QCOMPARE(entry2.completeSuffix(), completeSuffix); QCOMPARE(entry2.isAbsolute(), absolute); QCOMPARE(entry2.isRelative(), relative); QCOMPARE(entry2.filePath(), filepath); // Since this entry was created using the native path, // the object shouldnot change nativeFilePath. QCOMPARE(entry2.nativeFilePath(), nativeFilePath); QCOMPARE(entry2.fileName(), filename); QCOMPARE(entry2.baseName(), baseName); QCOMPARE(entry2.completeBaseName(), completeBasename); }
int Sender::init (int argc, ACE_TCHAR *argv[]) { // Initialize the endpoint strategy with the orb and poa. int result = this->endpoint_strategy_.init (TAO_AV_CORE::instance ()->orb (), TAO_AV_CORE::instance ()->poa ()); if (result != 0) return result; // Initialize the naming services result = this->naming_client_.init (TAO_AV_CORE::instance ()->orb ()); if (result != 0) return result; // Parse the command line arguments result = this->parse_args (argc, argv); if (result != 0) return result; // Open file to read. this->input_file_ = ACE_OS::fopen (this->filename_.c_str (), "r"); if (this->input_file_ == 0) ACE_ERROR_RETURN ((LM_DEBUG, "Cannot open input file %C\n", this->filename_.c_str ()), -1); else ACE_DEBUG ((LM_DEBUG, "File opened successfully\n")); // Resolve the object reference of the receiver from the Naming Service. result = this->bind_to_receiver (); if (result != 0) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) Error binding to the naming service\n"), -1); // Initialize the QoS AVStreams::streamQoS_var the_qos (new AVStreams::streamQoS); // Create the forward flow specification to describe the flow. TAO_Forward_FlowSpec_Entry entry ("Data_Receiver", "IN", "USER_DEFINED", "", this->protocol_.c_str (), 0); AVStreams::flowSpec flow_spec (1); flow_spec.length (2); flow_spec [0] = CORBA::string_dup (entry.entry_to_string ()); // Create the forward flow specification to describe the flow. TAO_Forward_FlowSpec_Entry entry1 ("Data_Receiver1", "OUT", "USER_DEFINED", "", this->protocol_.c_str (), 0); flow_spec [1] = CORBA::string_dup (entry1.entry_to_string ()); // Register the sender mmdevice object with the ORB ACE_NEW_RETURN (this->sender_mmdevice_, TAO_MMDevice (&this->endpoint_strategy_), -1); // Servant Reference Counting to manage lifetime PortableServer::ServantBase_var safe_mmdevice = this->sender_mmdevice_; AVStreams::MMDevice_var mmdevice = this->sender_mmdevice_->_this (); ACE_NEW_RETURN (this->streamctrl_, TAO_StreamCtrl, -1); PortableServer::ServantBase_var safe_streamctrl = this->streamctrl_; // Bind/Connect the sender and receiver MMDevices. CORBA::Boolean bind_result = this->streamctrl_->bind_devs (mmdevice.in (), this->receiver_mmdevice_.in (), the_qos.inout (), flow_spec); if (bind_result == 0) ACE_ERROR_RETURN ((LM_ERROR, "streamctrl::bind_devs failed\n"), -1); return 0; }
void process_refs(entry_ref /*dir*/, BMessage * msg, void * ) { type_code tc; int32 count=0; msg->GetInfo("refs",&tc,&count); if ( count != 2 ) { BAlert * alert = new BAlert("IM Alert", "You must select two files to merge","Ok"); alert->Go(); return; } entry_ref refs[2]; char name1[512], name2[512]; for ( int i=0; msg->FindRef("refs",i,&refs[i]) == B_OK; i++ ) { BNode node(&refs[i]); BNodeInfo info(&node); char type[512]; if ( info.GetType(type) != B_OK ) { // error BAlert * alert = new BAlert("IM Error", "Error reading file type", "Ok"); alert->Go(); return; } if ( strcmp(type,"application/x-person") != 0 ) { // error BAlert * alert = new BAlert("IM Error", "Wrong file type", "Ok"); alert->Go(); return; } } BEntry entry1( &refs[0] ); entry1.GetName( name1 ); BEntry entry2( &refs[1] ); entry2.GetName( name2 ); // got file info, now ask which direction to merge char a_to_b[1024], b_to_a[1024]; sprintf(a_to_b,"\"%s\" > \"%s\"", name1, name2 ); sprintf(b_to_a,"\"%s\" > \"%s\"", name2, name1 ); BAlert * alert = new BAlert( "IM Question", "Choose a merge direction. The file on the left side will be deleted.", a_to_b, b_to_a, "Cancel" ); int32 selection = alert->Go(); switch ( selection ) { case 0: // a_to_b merge_contacts(refs[0], refs[1]); break; case 1: // b_to_a merge_contacts(refs[1], refs[0]); break; default: // cancel break; } }
/* @file @SYMTestCaseID SYSLIB-SCHSVR-CIT-0279 @SYMTestCaseDesc Persistant schedule - UTC & Hometime @SYMTestPriority High @SYMTestActions For time and condition based test schedule task and check it fires @SYMTestExpectedResults The test must not fail. @SYMPREQ PREQ234 */ TVerdict Cpersist_mixedStep::doTestStepL() /** * @return - TVerdict code * Override of base class pure virtual * Our implementation only gets called if the base class doTestStepPreambleL() did * not leave. That being the case, the current test result value will be EPass. */ { SetTestStepResult(EFail); _LIT(KTestName1, "Persistant Mixed - Hometime"); _LIT(KTaskData1, "This is some really exciting task data (number 1)"); _LIT(KTestName2, "Persistant Mixed - UTC"); _LIT(KTaskData2, "This is some really exciting task data (number 2)"); // Tests with timezone set to Europe, London RTz tz; tz.Connect(); CTzId* tzId = CTzId::NewL(2592); //set the timezone to Europe/London CleanupStack::PushL(tzId); tz.SetTimeZoneL(*tzId); // Set the time to a known value, since this makes testing much easier (and more // repeatable). SchSvrHelpers::SetUTCTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 55, 0, 0))); // 9:55 am // Prepare schedules describing when we want the tasks to run (10:00 am & 10.00) // Creates a hometime based daily persistant schedule TSchedulerItemRef ref1; // This is the time when we want the Hometime time-based schedule to fire TDateTime datetime1(2000, EJanuary, 1, 11, 0, 0, 0); TTsTime startTimeForSchedule1(datetime1, EFalse); // 11:00 am { CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1); CleanupStack::PushL(entryList); TScheduleEntryInfo2 entry1 (startTimeForSchedule1, EDaily, 1, 30); entryList->AppendL(entry1); TInt res = TheScheduler.CreatePersistentSchedule(ref1, *entryList); TESTL(res==KErrNone); CleanupStack::PopAndDestroy(); // entryList } // Disable the schedule whilst we set it up User::LeaveIfError(TheScheduler.DisableSchedule(ref1.iHandle)); // Creates a UTC based daily persistant schedule TSchedulerItemRef ref2; // This is the time when we want the UTC time-based schedule to fire TDateTime datetime2(2000, EJanuary, 1, 10, 0, 0, 0); TTsTime startTimeForSchedule2(datetime2, ETrue); // 10:00 am { CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1); CleanupStack::PushL(entryList); TScheduleEntryInfo2 entry1 (startTimeForSchedule2, EDaily, 1, 30); entryList->AppendL(entry1); TInt res = TheScheduler.CreatePersistentSchedule(ref2, *entryList); TESTL(res==KErrNone); CleanupStack::PopAndDestroy(); // entryList } // Disable the schedule whilst we set it up User::LeaveIfError(TheScheduler.DisableSchedule(ref2.iHandle)); // Kill the server to check if persisted schedules have been stored // Need to turn off JIT dubugging as we are panicking server and we // want test to keep running. TBool jit = User::JustInTime(); User::SetJustInTime(EFalse); TheScheduler.__FaultServer(); // Change UTC Offset whilst server is down // Set UTC offset to +1Hr by moving to Europe, Paris tzId = CTzId::NewL(2656); //set the timezone to Europe/Paris tz.SetTimeZoneL(*tzId); User::After(1000000); // Turn on JIT again. User::SetJustInTime(jit); // Connect to the server again TInt res = TheScheduler.Connect(); TESTL(res==KErrNone); // Re-register TESTL(SchSvrHelpers::RegisterClientL(TheScheduler)==KErrNone); // Associate a task with the time-based schedule TTaskInfo taskInfo1; taskInfo1.iName = KTestName1; taskInfo1.iPriority = 2; taskInfo1.iRepeat = 0; // Create some data associated with this task HBufC* taskData1 = KTaskData1().AllocLC(); User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo1, *taskData1, ref1.iHandle)); CleanupStack::PopAndDestroy(); // taskData1 // Associate a task with the condition-based schedule TTaskInfo taskInfo2; taskInfo2.iName = KTestName2; taskInfo2.iPriority = 2; taskInfo2.iRepeat = 0; // Create some data associated with this task HBufC* taskData2 = KTaskData2().AllocLC(); User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo2, *taskData2, ref2.iHandle)); CleanupStack::PopAndDestroy(); // taskData2 // Set the UTC time such that both schedules fire at the same time SchSvrHelpers::SetUTCTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 59, 50, 0))); // 9:59.50 am User::LeaveIfError(TheScheduler.EnableSchedule(ref1.iHandle)); User::LeaveIfError(TheScheduler.EnableSchedule(ref2.iHandle)); // Now wait for the time-based schedule to fire TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone); // Now wait for the condition-based schedule to fire TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone); TTime timeNow; timeNow.HomeTime(); TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, EFalse), startTimeForSchedule1)); timeNow.UniversalTime(); TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, ETrue), startTimeForSchedule2)); CleanupStack::PopAndDestroy(); // timezone ID CleanupHelpers::KillProcess(KMinimalTaskHandler); SetTestStepResult(EPass); return TestStepResult(); }