bool TextInput::operator==(const TextInput &other) const { return d->title == other.title() && d->description == other.description() && d->name == other.name() && d->link == other.link(); }
void Any::deserialize(TextInput& ti) { beforeRead(); Token token = ti.read(); deserialize(ti, token); // Restore the last token ti.push(token); }
static Vector3 readNormal(TextInput& ti, const Matrix3& normalXform) { Vector3 n; n.x = ti.readNumber(); n.y = ti.readNumber(); n.z = ti.readNumber(); return (normalXform * n).direction(); }
bool GPUProgram::BindingTable::consumeSymbol(TextInput& ti, const std::string& s) { Token t = ti.peek(); if (symbolMatch(t, s)) { ti.readSymbol(s); return true; } else { return false; } }
static Vector3 readVertex(TextInput& ti, const Matrix4& xform) { // Vertex Vector4 v; v.x = ti.readNumber(); v.y = ti.readNumber(); v.z = ti.readNumber(); v.w = 1.0f; return (xform * v).xyz(); }
/** True if the next token begins the close tag */ static bool atClose(TextInput& t, const std::string name) { if ((t.peek().type() == Token::SYMBOL) && (t.peek().string() == "<")) { // Need to keep looking ahead Token p0 = t.read(); if ((t.peek().type() == Token::SYMBOL) && (t.peek().string() == "/")) { // Check the name on the close tag. It *must* match if // this is a well-formed document, but there might be a // tag error. Token p1 = t.read(); Token p2 = t.peek(); std::string s = p2.string(); debugAssertM(beginsWith(name, s), "Mismatched close tag"); // Put the tokens back t.push(p1); t.push(p0); return true; } else { // Put the read token back t.push(p0); return false; } } else { return false; } }
void DeviceTestApp::processTap( ivec2 pos ) { // TextInput *selectedInput = false; if( mPlayButton.hitTest( pos ) ) audio::master()->setEnabled( ! audio::master()->isEnabled() ); else if( mRecordButton.hitTest( pos ) ) startRecording(); else if( mSamplerateInput.hitTest( pos ) ) { } else if( mFramesPerBlockInput.hitTest( pos ) ) { } else if( mNumInChannelsInput.hitTest( pos ) ) { } else if( mNumOutChannelsInput.hitTest( pos ) ) { } else if( mSendChannelInput.hitTest( pos ) ) { } #if defined( CINDER_COCOA_TOUCH ) TextInput *currentSelected = TextInput::getCurrentSelected(); if( currentSelected ) showKeyboard( KeyboardOptions().type( KeyboardType::NUMERICAL ).initialString( currentSelected->mInputString ) ); #endif size_t currentTestIndex = mTestSelector.mCurrentSectionIndex; if( mTestSelector.hitTest( pos ) && currentTestIndex != mTestSelector.mCurrentSectionIndex ) { string currentTest = mTestSelector.currentSection(); CI_LOG_V( "selected: " << currentTest ); setupTest( currentTest ); return; } size_t currentOutputIndex = mOutputSelector.mCurrentSectionIndex; if( mOutputSelector.hitTest( pos ) && currentOutputIndex != mOutputSelector.mCurrentSectionIndex ) { auto dev = audio::Device::findDeviceByName( mOutputSelector.mSegments[mOutputSelector.mCurrentSectionIndex] ); CI_LOG_V( "selected output device named: " << dev->getName() << ", key: " << dev->getKey() ); setOutputDevice( dev ); return; } size_t currentInputIndex = mInputSelector.mCurrentSectionIndex; if( mInputSelector.hitTest( pos ) && currentInputIndex != mInputSelector.mCurrentSectionIndex ) { auto dev = audio::Device::findDeviceByName( mInputSelector.mSegments[mInputSelector.mCurrentSectionIndex] ); CI_LOG_V( "selected input named: " << dev->getName() << ", key: " << dev->getKey() ); setInputDevice( dev ); return; } }
void DeviceTestApp::keyDown( KeyEvent event ) { TextInput *currentSelected = TextInput::getCurrentSelected(); if( ! currentSelected ) return; if( event.getCode() == KeyEvent::KEY_RETURN ) { #if defined( CINDER_COCOA_TOUCH ) hideKeyboard(); #endif try { if( currentSelected == &mSamplerateInput ) { int sr = currentSelected->getValue(); CI_LOG_V( "updating samplerate from: " << mOutputDeviceNode->getSampleRate() << " to: " << sr ); mOutputDeviceNode->getDevice()->updateFormat( audio::Device::Format().sampleRate( sr ) ); } else if( currentSelected == &mFramesPerBlockInput ) { int frames = currentSelected->getValue(); CI_LOG_V( "updating frames per block from: " << mOutputDeviceNode->getFramesPerBlock() << " to: " << frames ); mOutputDeviceNode->getDevice()->updateFormat( audio::Device::Format().framesPerBlock( frames ) ); } else if( currentSelected == &mNumInChannelsInput ) { int numChannels = currentSelected->getValue(); CI_LOG_V( "updating nnm input channels from: " << mInputDeviceNode->getNumChannels() << " to: " << numChannels ); setInputDevice( mInputDeviceNode->getDevice(), numChannels ); } else if( currentSelected == &mNumOutChannelsInput ) { int numChannels = currentSelected->getValue(); CI_LOG_V( "updating nnm output channels from: " << mOutputDeviceNode->getNumChannels() << " to: " << numChannels ); setOutputDevice( mOutputDeviceNode->getDevice(), numChannels ); } else if( currentSelected == &mSendChannelInput ) { if( mTestSelector.currentSection() == "send" || mTestSelector.currentSection() == "send stereo" ) setupTest( mTestSelector.currentSection() ); } else CI_LOG_E( "unhandled return for string: " << currentSelected->mInputString ); } catch( audio::AudioDeviceExc &exc ) { CI_LOG_E( "AudioDeviceExc caught, what: " << exc.what() ); auto ctx = audio::master(); mSamplerateInput.setValue( ctx->getSampleRate() ); mFramesPerBlockInput.setValue( ctx->getFramesPerBlock() ); return; } } else { if( event.getCode() == KeyEvent::KEY_BACKSPACE ) currentSelected->processBackspace(); else { currentSelected->processChar( event.getChar() ); } } }
int UtcDaliTextInputTextSelection(void) { ToolkitTestApplication application; tet_infoline("Testing Text Selection"); const std::string initialString = "initial text"; TextInput textInput = TextInput::New(); textInput.SetInitialText( initialString ); Stage::GetCurrent().Add(textInput); application.SendNotification(); application.Render(); textInput.SetEditable( true ); tet_infoline("Testing IsTextSelected negative"); DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION); textInput.SelectText(1,7); DALI_TEST_EQUALS( true, textInput.IsTextSelected(), TEST_LOCATION); textInput.DeSelectText(); DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION); END_TEST; }
int UtcDaliTextInputSetAndGetNumberOfLines(void) { ToolkitTestApplication application; tet_infoline("Ensuring API for setting and getting max number of lines is correct"); TextInput textInput = TextInput::New(); // create empty TextInput unsigned int numberOfLines = 1; textInput.SetNumberOfLinesLimit( numberOfLines ); DALI_TEST_EQUALS(numberOfLines ,textInput.GetNumberOfLinesLimit(), TEST_LOCATION); END_TEST; }
int UtcDaliTextInputSetSortModifier(void) { tet_infoline("Testing SetSortModifier does not cause TextInput failure"); ToolkitTestApplication application; TextInput textInput = TextInput::New(); const float offsetToUse = 1.5f; textInput.SetSortModifier( offsetToUse ); DALI_TEST_CHECK( textInput ); END_TEST; }
void Any::deserializeName(TextInput& ti, Token& token, std::string& name) { debugAssert(token.type() == Token::SYMBOL); std::string s = token.string(); while (!isOpen(s[0])) { name += s; // Skip newlines and comments token = ti.readSignificant(); if (token.type() != Token::SYMBOL) { throw ParseError(ti.filename(), token.line(), token.character(), "Expected symbol while parsing Any"); } s = token.string(); } }
int UtcDaliTextInputSetAndGetTextAlignment(void) { ToolkitTestApplication application; TextInput textInput = TextInput::New(); Stage::GetCurrent().Add(textInput); application.SendNotification(); application.Render(); textInput.SetTextAlignment(static_cast<Alignment::Type>( Alignment::HorizontalCenter) ); application.SendNotification(); application.Render(); DALI_TEST_CHECK( static_cast<Alignment::Type>( Alignment::HorizontalCenter) & textInput.GetTextAlignment()) ; END_TEST; }
void Any::readUntilCommaOrClose(TextInput& ti, Token& token) { while (!(((token.type() == Token::SYMBOL) && (isClose(token.string()[0]))) || isSeparator(token.string()[0]))) { switch (token.type()) { case Token::NEWLINE: case Token::COMMENT: // Consume token = ti.read(); break; default: throw ParseError(ti.filename(), token.line(), token.character(), "Expected a comma or close paren"); } } }
int UtcDaliTextInputSetAndGetSnapshotModeEnabled(void) { ToolkitTestApplication application; tet_infoline("Testing SetSnapshotModeEnabled and IsSnapshotModeEnabled"); TextInput textInput = TextInput::New(); // create empty TextInput bool snapshotMode( true ); textInput.SetSnapshotModeEnabled( snapshotMode ); DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION); snapshotMode = false; textInput.SetSnapshotModeEnabled( snapshotMode ); DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION); END_TEST; }
// Positive test case for a method int UtcDaliTextInputGetText(void) { ToolkitTestApplication application; tet_infoline("Testing GetText"); const std::string teststring = "test"; TextInput textInput = TextInput::New(); // create empty TextInput DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION); // Get text which should be empty textInput.SetInitialText(teststring); DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be test string END_TEST; }
int UtcDaliTextInputEnableGrabHandleAndIsGrabHandleEnabled(void) { ToolkitTestApplication application; TextInput textInput = TextInput::New(); bool grabHandleState = false; textInput.EnableGrabHandle( grabHandleState ); DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION); grabHandleState = true; textInput.EnableGrabHandle( grabHandleState ); DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION); END_TEST; }
void Vector3::deserialize(TextInput& t) { t.readSymbol("("); x = (float)t.readNumber(); t.readSymbol(","); y = (float)t.readNumber(); t.readSymbol(","); z = (float)t.readNumber(); t.readSymbol(")"); }
int UtcDaliTextInputSetMaxCharacterLength(void) { ToolkitTestApplication application; tet_infoline("Testing Setting of max characters"); const int maxChars = 4; const char* testChar = "v"; TextInput textInput = TextInput::New(); // create empty TextInput Stage::GetCurrent().Add(textInput); application.SendNotification(); application.Render(); textInput.SetMaxCharacterLength(maxChars); Integration::KeyEvent event(testChar, testChar, 0, 0, 0, Integration::KeyEvent::Down ); std::string testString = ""; tet_infoline("Starting editmode"); textInput.SetEditable( true ); tet_infoline("Sending Key Events"); // Send max number of characters for (int i=0; i < maxChars; i++) { application.ProcessEvent(event); testString.append(testChar); } tet_printf( "Get text result : %s\n", textInput.GetText().c_str()); DALI_TEST_EQUALS(testString, textInput.GetText(), TEST_LOCATION); tet_infoline("Sending Key Event which exceeds max characters"); application.ProcessEvent(event); // try to append additional character DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION); tet_infoline("Increase max characters limit"); textInput.SetMaxCharacterLength(maxChars+1); // increment max characters by 1 tet_infoline("Send character again which should now fit"); application.ProcessEvent(event); // append additional character testString.append(testChar); DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION); END_TEST; }
int UtcDaliTextInputSetEditOnTouch(void) { ToolkitTestApplication application; tet_infoline("Testing SetEditOnTouch And IsEditOnTouch"); TextInput textInput = TextInput::New(); bool editableOnTouchOn ( true ); bool editableOnTouchOff( false ); tet_infoline("Testing SetEditOnTouch disabled"); textInput.SetEditOnTouch ( editableOnTouchOff ); DALI_TEST_EQUALS( editableOnTouchOff, textInput.IsEditOnTouch() , TEST_LOCATION); tet_infoline("Testing SetEditOnTouch enabled"); textInput.SetEditOnTouch ( editableOnTouchOn ); DALI_TEST_EQUALS( editableOnTouchOn, textInput.IsEditOnTouch() , TEST_LOCATION); END_TEST; }
std::string _test_ifile(TextInput a) { std::string read; while (true) { std::string cur; a.get_stream() >> cur; if (!a) break; read = read + cur; } std::cout << read; return read; }
int UtcDaliTextInputSetAndGetHeightExceedPolicy(void) { ToolkitTestApplication application; tet_infoline("UtcDaliTextInputSetAndGetHeightExceedPolicy: "); const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit }; const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int ); TextInput textInput = TextInput::New(); textInput.SetInitialText( "Hello world!" ); for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex ) { textInput.SetHeightExceedPolicy( EXCEED_POLICIES[epIndex] ); DALI_TEST_EQUALS( textInput.GetHeightExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION ); } END_TEST; }
int UtcDaliTextInputEndSignalEmit(void) { ToolkitTestApplication application; tet_infoline("Testing Set editable false emits end signal"); TextInput textInput = TextInput::New(); // create empty TextInput Stage::GetCurrent().Add(textInput); textInput.InputFinishedSignal().Connect( &OnEndInput ); textInput.SetEditable(true) ; gHasEndSignalBeenReceived = false; textInput.SetEditable(false) ; DALI_TEST_EQUALS(true, gHasEndSignalBeenReceived, TEST_LOCATION); END_TEST; }
int UtcDaliTextInputSetAndGetBoundingRectangle(void) { ToolkitTestApplication application; TextInput textInput = TextInput::New(); Stage::GetCurrent().Add(textInput); Vector2 stageSize = Stage::GetCurrent().GetSize(); const Rect<float> boundingRectangle( 100.0f, 100.0f, stageSize.width, stageSize.height ); textInput.SetBoundingRectangle( boundingRectangle ); const Rect<float> retreievedBoundingRectangle = textInput.GetBoundingRectangle(); DALI_TEST_EQUALS( boundingRectangle.x, retreievedBoundingRectangle.x, TEST_LOCATION); DALI_TEST_EQUALS( boundingRectangle.y, retreievedBoundingRectangle.y, TEST_LOCATION); DALI_TEST_EQUALS( boundingRectangle.width, retreievedBoundingRectangle.width, TEST_LOCATION); DALI_TEST_EQUALS( boundingRectangle.height, retreievedBoundingRectangle.height, TEST_LOCATION); END_TEST; }
int UtcDaliTextInputExceedMaxCharacters(void) { ToolkitTestApplication application; tet_infoline("Testing Max characters is obeyed when inputting key events "); TextInput textInput = TextInput::New(); // create empty TextInput Stage::GetCurrent().Add(textInput); textInput.SetMaxCharacterLength(4); textInput.SetInitialText(""); textInput.SetEditable(true); application.SendNotification(); application.Render(); Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down ); Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down ); application.ProcessEvent(eventA); application.ProcessEvent(eventB); application.ProcessEvent(eventA); application.ProcessEvent(eventB); application.ProcessEvent(eventA); application.ProcessEvent(eventB); tet_printf( "Get text result : %s\n", textInput.GetText().c_str()); DALI_TEST_EQUALS("abab",textInput.GetText(), TEST_LOCATION); // Get text which should be only 4 characters END_TEST; }
int UtcDaliTextInputStartSignalEmit(void) { ToolkitTestApplication application; tet_infoline("Testing SetEditable emits start signal"); TextInput textInput = TextInput::New(); // create empty TextInput Stage::GetCurrent().Add(textInput); textInput.InputStartedSignal().Connect( &OnStartInput ); gHasStartSignalBeenReceived = false; textInput.SetEditable(true); // Set editable first time DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION); gHasStartSignalBeenReceived = false; textInput.SetEditable(true); // Set editable second time, signal should not be sent again. DALI_TEST_EQUALS(false, gHasStartSignalBeenReceived, TEST_LOCATION); textInput.SetEditable(false); gHasStartSignalBeenReceived = false; textInput.SetEditable(true); // Set editable again DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION); END_TEST; }
int UtcDaliTextInputSetAndGetPlaceholderText(void) { ToolkitTestApplication application; tet_infoline("Testing Setting of PlaceholderText"); const std::string initialString = "initial text"; const std::string placeholderString = "placeholder"; TextInput textInput = TextInput::New(); // create empty TextInput tet_infoline("Testing TextInput is empty at creation "); DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION); tet_infoline("Set placeholder text"); textInput.SetPlaceholderText( placeholderString ); tet_infoline("Testing TextInput contains placeholder text"); DALI_TEST_EQUALS( placeholderString , textInput.GetPlaceholderText(), TEST_LOCATION); tet_infoline("Set initial text which should replace placeholder text"); textInput.SetInitialText( initialString ); tet_infoline("Testing TextInput contains initial text when placeholder text set"); DALI_TEST_EQUALS( initialString,textInput.GetText(), TEST_LOCATION); END_TEST; }
int UtcDaliTextInputSetEditableAndIsEditable(void) { ToolkitTestApplication application; tet_infoline("Testing SetEditable And IsEditable"); const std::string initialString = "initial text"; TextInput textInput = TextInput::New(); // create empty TextInput textInput.SetInitialText( initialString ); Stage::GetCurrent().Add(textInput); application.SendNotification(); application.Render(); bool editableStateFalse ( false ); bool editableStateTrue ( true ); textInput.SetEditable ( editableStateFalse ); application.SendNotification(); application.Render(); DALI_TEST_EQUALS( editableStateFalse, textInput.IsEditable() , TEST_LOCATION); textInput.SetEditable ( editableStateTrue ); application.SendNotification(); application.Render(); DALI_TEST_EQUALS( editableStateTrue, textInput.IsEditable() , TEST_LOCATION); END_TEST; }
Hierarchy read_mol2(TextInput mol2_file, Model* model, Mol2Selector* mol2sel) { if (!mol2sel) { mol2sel = new AllMol2Selector(); } IMP::PointerMember<Mol2Selector> sel(mol2sel); // create a map to save atom_index and atom particle pairs boost::unordered_map<Int, Particle*> molecule_atoms; // create root particle Hierarchy root_d = root_particle(model, mol2_file.get_name()); std::string line; Hierarchy molecule_d; while (std::getline(mol2_file.get_stream(), line)) { // check the line is the title line @<TRIPOS>MOLECULE if (internal::is_MOLECULE_rec(line)) { molecule_atoms.clear(); molecule_d = read_molecule_mol2(model, mol2_file, root_d); } // check the starting line of atom block @<TRIPOS>ATOM else if (internal::is_MOL2ATOM_rec(line)) { if (!molecule_d) { IMP_THROW("Atom seen before molecule on line " << line, IOException); } read_atom_mol2(model, mol2_file, molecule_d, molecule_atoms, mol2sel); } // check the starting line of bond block @<TRIPOS>BOND else if (internal::is_BOND_rec(line)) { read_bond_mol2(model, mol2_file, molecule_d, molecule_atoms); } else { IMP_LOG_TERSE("Couldn't parse line " << line << std::endl); } } // Hierarchies mps = get_by_type(root_d, RESIDUE_TYPE); // std::cout << "check " << mps.size() << std::endl; add_radii(root_d); IMP_INTERNAL_CHECK(root_d.get_is_valid(true), "Invalid hierarchy produced"); return root_d; }
// Positive test case for a method int UtcDaliTextInputSetInitialText(void) { ToolkitTestApplication application; tet_infoline("Testing Setting of Initial Text"); const std::string teststring = "test"; TextInput textInput = TextInput::New(); // create empty TextInput tet_infoline("Testing TextInput is empty at creation "); DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION); tet_infoline("Set text to TextInput"); textInput.SetInitialText(teststring); tet_infoline("Test TextInput contains set text"); DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION); END_TEST; }