// See if we get a memory leak using 'AddFeature'. I doubt we'll even see // an out of memory issue here (despite the environment). TEF will ignore // errors (with the !OOM option). TVerdict CFeatureAddFeatureOOMTestStep::doTestStepL() { // Try to add already existing feature. TBitFlags32 flags( 0 ); flags.Set( EFeatureSupported ); flags.Set( EFeatureModifiable ); TFeatureEntry entry( KDefaultSupportedUid, flags, KDefaultData1 ); TInt err = icontrol.AddFeature( entry ); TESTDIAGNOSTICERROR(err == KErrAlreadyExists, _L("RFeatureControl::AddFeature - KErrAlreadyExists expected; error = %d"),err); // Add new feature. If test run sequentially, feature already exists TFeatureEntry entry2( KNewUid, flags, KDefaultData1 ); err = icontrol.AddFeature( entry2 ); TESTDIAGNOSTICERROR(err == KErrNone || err == KErrAlreadyExists, _L("RFeatureControl::AddFeature - KErrNone or KErrAlreadyExists expected; error = %d"),err); TBitFlags32 flags1( 0 ); flags1.Set( EFeatureUninitialized ); flags1.Set( EFeatureModifiable ); TFeatureEntry entry3( KNewUid1, flags1, KDefaultData1 ); err = icontrol.AddFeature( entry3 ); TESTDIAGNOSTICERROR(err == KErrNone || err == KErrAlreadyExists, _L("RFeatureControl::AddFeature - KErrNone or KErrAlreadyExists expected; error = %d"),err); return TestStepResult(); }
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); }
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(); }
TEST (kdbrestModelsEntryTest, GetPublicNameErasing) { kdb::Key key (kdbrest::Config::instance ().getConfig ().get<std::string> ("kdb.path.configs") + std::string ("/test/key1"), KEY_END); kdbrest::model::Entry entry (key); ASSERT_NE (entry.getPublicName (), entry.getName ()); ASSERT_NE (entry.getPublicName (), key.getName ()); std::string entryName2 ("test/key1"); kdbrest::model::Entry entry2 (entryName2); ASSERT_NE (entry2.getPublicName (), entry2.getName ()); }
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(); }
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); }
TEST (kdbrestModelsEntryTest, SetAndGetAndAddSubkeys) { kdb::Key key (kdbrest::Config::instance ().getConfig ().get<std::string> ("kdb.path.configs") + std::string ("/test/key1"), KEY_END); kdb::Key key2 (kdbrest::Config::instance ().getConfig ().get<std::string> ("kdb.path.configs") + std::string ("/test/key1/subkey1"), KEY_END); kdb::Key key3 (kdbrest::Config::instance ().getConfig ().get<std::string> ("kdb.path.configs") + std::string ("/test/key1/subkey1/subkey2"), KEY_END); kdb::Key key4 (kdbrest::Config::instance ().getConfig ().get<std::string> ("kdb.path.configs") + std::string ("/test/key2/subkey1"), KEY_END); kdbrest::model::Entry entry (key); entry.addSubkey (key2, true); ASSERT_EQ (entry.getSubkeys ().size (), 1); entry.addSubkey (key3, true); ASSERT_EQ (entry.getSubkeys ().size (), 2); entry.addSubkey (key4, true); ASSERT_EQ (entry.getSubkeys ().size (), 2); ASSERT_TRUE (entry.getSubkeys ().lookup (key2)); ASSERT_TRUE (entry.getSubkeys ().lookup (key3)); kdb::KeySet ks; ks.append (key2); ks.append (key3); ks.append (key4); kdbrest::model::Entry entry2 (key); entry2.addSubkeys (ks, true); ASSERT_EQ (entry2.getSubkeys ().size (), 2); ASSERT_TRUE (entry2.getSubkeys ().lookup (key2)); ASSERT_TRUE (entry2.getSubkeys ().lookup (key3)); }
void DsrCacheEntryTest::DoRun () { Ptr<dsr::RouteCache> rcache = CreateObject<dsr::RouteCache> (); std::vector<Ipv4Address> ip; ip.push_back (Ipv4Address ("0.0.0.0")); ip.push_back (Ipv4Address ("0.0.0.1")); Ipv4Address dst = Ipv4Address ("0.0.0.1"); dsr::RouteCacheEntry entry (ip, dst, Seconds (1)); NS_TEST_EXPECT_MSG_EQ (entry.GetVector ().size (), 2, "trivial"); NS_TEST_EXPECT_MSG_EQ (entry.GetDestination (), Ipv4Address ("0.0.0.1"), "trivial"); NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (1), "trivial"); entry.SetExpireTime (Seconds (3)); NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (3), "trivial"); entry.SetDestination (Ipv4Address ("1.1.1.1")); NS_TEST_EXPECT_MSG_EQ (entry.GetDestination (), Ipv4Address ("1.1.1.1"), "trivial"); ip.push_back (Ipv4Address ("0.0.0.2")); entry.SetVector (ip); NS_TEST_EXPECT_MSG_EQ (entry.GetVector ().size (), 3, "trivial"); NS_TEST_EXPECT_MSG_EQ (rcache->AddRoute (entry), true, "trivial"); std::vector<Ipv4Address> ip2; ip2.push_back (Ipv4Address ("1.1.1.0")); ip2.push_back (Ipv4Address ("1.1.1.1")); Ipv4Address dst2 = Ipv4Address ("1.1.1.1"); dsr::RouteCacheEntry entry2 (ip2, dst2, Seconds (2)); dsr::RouteCacheEntry newEntry; NS_TEST_EXPECT_MSG_EQ (rcache->AddRoute (entry2), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rcache->LookupRoute (dst2, newEntry), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rcache->DeleteRoute (Ipv4Address ("2.2.2.2")), false, "trivial"); NS_TEST_EXPECT_MSG_EQ (rcache->DeleteRoute (Ipv4Address ("1.1.1.1")), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rcache->DeleteRoute (Ipv4Address ("1.1.1.1")), false, "trivial"); }
unsigned int near entry_c(void) { dos_puts(hello_world); dos_puts(hellostr2); entry2(); return 0; }
void TPanelWindowView::AttachedToWindow() { fTimer = new BMessageRunner( BMessenger(Window()), new BMessage(kPanelWindowViewTimer), 999999 ); new BMessageRunner( BMessenger(this), new BMessage(kDoBubbleHelp), 100000 ); fLastActiveAppIcon = 0, be_roster->StartWatching( BMessenger(this), B_REQUEST_LAUNCHED|B_REQUEST_QUIT|B_REQUEST_ACTIVATED ); fUseWindowShapping = false; fOuterFrameColor = (rgb_color){96,96,96,255}; fBubbleHelp = new TBubbleHelp(); if ( fThisArchive ) { // todo fColor3 = (rgb_color){218,218,205,255}; if ( fThisArchive->FindBool( "TransparentMenus", &fUseTransparentMenus ) != B_OK ) fUseTransparentMenus = false; if ( fThisArchive->FindInt32( "Location", &fLocation ) != B_OK ) fLocation = kLocationBottom; rgb_color *temp_c; ssize_t _size; if ( fThisArchive->FindData( "BackColor", B_RGB_COLOR_TYPE, (const void**)&temp_c, &_size ) != B_OK) fColor2 = (rgb_color){229,235,231,255}; else fColor2 = *temp_c; if ( fThisArchive->FindData( "OuterFrameColor", B_RGB_COLOR_TYPE, (const void**)&temp_c, &_size ) != B_OK) fOuterFrameColor = (rgb_color){96,96,96,255}; else fOuterFrameColor = *temp_c; if ( fThisArchive->FindBool( "DrawOuterFrame", &fDrawOuterFrame ) != B_OK ) fDrawOuterFrame = true; #ifdef USE_WINDOW_SHAPING if ( fThisArchive->FindBool( "UseWindowShapping", &fUseWindowShapping ) != B_OK ) fUseWindowShapping = true; ((TPanelWindow*)Window())->SetShowHideLimit( fUseWindowShapping ? 0.1f : 0.f ); #endif bool autohide; if ( fThisArchive->FindBool( "AutoHide", &autohide ) != B_OK ) autohide = false; ((TPanelWindow*)Window())->SetAutoHide( autohide ); int32 delay; if ( fThisArchive->FindInt32( "HideEffectDelay", &delay ) != B_OK ) delay = kWindowHidderAnimationStaleSpeed; ((TPanelWindow*)Window())->SetHideEffectDelay( delay ); if ( fThisArchive->FindBool( "AlwaysOnTop", &fAlwaysOnTop ) != B_OK ) fAlwaysOnTop = true; if ( fThisArchive->FindBool( "HideStandardDeskbar", &fHideStandardDeskbar ) != B_OK ) fHideStandardDeskbar = false; if ( fHideStandardDeskbar ) { BMessage msg(B_SET_PROPERTY); msg.AddBool( "data", true ); msg.AddSpecifier( "Hidden" ); msg.AddSpecifier( "Window", "Deskbar" ); be_app->PostMessage(&msg); } for ( int i=0; ; i++ ) { BMessage inner; if ( fThisArchive->FindMessage( "tabs", i, &inner ) != B_OK ) break; inner.AddPointer( "parent", this ); BArchivable *archive = instantiate_dock_object( &inner ); if ( archive ) { TInnerPanel *panel = dynamic_cast<TInnerPanel*>(archive); if ( panel ) { AddPanel( panel ); bool _isr; if ( inner.FindBool( "IsRunningAppPanel", &_isr ) == B_OK && _isr ) fRunningAppPanel = cast_as( panel, TApplicationPanel ); } } } delete fThisArchive; fThisArchive = 0; } else { // <options> fUseTransparentMenus = false; fLocation = kLocationBottom; fColor2 = (rgb_color){229,235,231,255}; fColor3 = (rgb_color){218,218,205,255}; fDrawOuterFrame = true; fUseWindowShapping = false; fHideStandardDeskbar = false; fAlwaysOnTop = false; // </options> } if ( fAlwaysOnTop ) Window()->SetFeel( B_FLOATING_ALL_WINDOW_FEEL ); else Window()->SetFeel( B_NORMAL_WINDOW_FEEL ); if ( fPanels.CountItems() == 0 ) { TShortcutPanel *cpanel = new TShortcutPanel(this); AddPanel( cpanel ); cpanel->AddItem( new TTrashIcon() ); cpanel->AddItem( new TWorkspacesIcon() ); cpanel->AddItem( new TClockIcon() ); BEntry entry( "/boot/beos/system/Tracker" ); entry_ref ref; entry.GetRef( &ref ); AddShortcut( cpanel, ref ); BPath path; if ( find_directory( B_USER_CONFIG_DIRECTORY, &path ) == B_OK ) { path.Append( "be" ); BEntry entry2( path.Path() ); entry2.GetRef( &ref ); AddShortcut( cpanel, ref ); } cpanel = new TShortcutPanel(this); AddPanel( cpanel ); AddShortcut( cpanel, "application/x-vnd.Be-NPOS" ); AddShortcut( cpanel, "application/x-vnd.Sugoi-BeShare" ); fRunningAppPanel = new TApplicationPanel(this); AddPanel( fRunningAppPanel ); } // AddPanel( new TReplicantShelfPanel(this) ); }
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; } }
bool SearchForSignatureEntryList::CanOpenWithFilter(const Model* appModel, const BMessage* entriesToOpen, const entry_ref* preferredApp) { ThrowOnAssert(appModel != NULL); if (!appModel->IsExecutable() || !appModel->Node()) { // weed out non-executable #if xDEBUG BPath path; BEntry entry(appModel->EntryRef()); entry.GetPath(&path); PRINT(("filtering out %s- not executable \n", path.Path())); #endif return false; } if (strcasecmp(appModel->MimeType(), B_APP_MIME_TYPE) != 0) { // filter out pe containers on PPC etc. return false; } BFile* file = dynamic_cast<BFile*>(appModel->Node()); ASSERT(file != NULL); char signature[B_MIME_TYPE_LENGTH]; if (GetAppSignatureFromAttr(file, signature) == B_OK && strcasecmp(signature, kTrackerSignature) == 0) { // special case the Tracker - make sure only the running copy is // in the list app_info trackerInfo; if (*appModel->EntryRef() != trackerInfo.ref) { // this is an inactive copy of the Tracker, remove it #if xDEBUG BPath path1; BPath path2; BEntry entry(appModel->EntryRef()); entry.GetPath(&path1); BEntry entry2(&trackerInfo.ref); entry2.GetPath(&path2); PRINT(("filtering out %s, sig %s, active Tracker at %s, " "result %s, refName %s\n", path1.Path(), signature, path2.Path(), strerror(be_roster->GetActiveAppInfo(&trackerInfo)), trackerInfo.ref.name)); #endif return false; } } if (FSInTrashDir(appModel->EntryRef())) return false; if (ShowAllApplications()) { // don't check for these if we didn't look for every single app // to not slow filtering down uint32 flags; BAppFileInfo appFileInfo(dynamic_cast<BFile*>(appModel->Node())); if (appFileInfo.GetAppFlags(&flags) != B_OK) return false; if ((flags & B_BACKGROUND_APP) || (flags & B_ARGV_ONLY)) return false; if (!signature[0]) // weed out apps with empty signatures return false; } int32 relation = Relation(entriesToOpen, appModel, preferredApp, 0); if (relation == kNoRelation && !ShowAllApplications()) { #if xDEBUG BPath path; BEntry entry(appModel->EntryRef()); entry.GetPath(&path); PRINT(("filtering out %s, does not handle any of opened files\n", path.Path())); #endif return false; } if (relation != kNoRelation && relation != kSuperhandler && !fGenericFilesOnly) { // we hit at least one app that is not a superhandler and // handles the document fFoundOneNonSuperHandler = true; } return true; }