void UiPropertyGrid::AddTextureElement( SceneManager::Property* property, const std::string& group ) { std::string groupParam( std::string(UI_PARAM_GROUP) + "'" + group + "'" ); AddSeparator(groupParam); //Add path selected std::string path; property->GetValue(path); bool IsFileSet = false; std::string file; if ( path.size() == 0 ) { file = "Not set"; } else { IsFileSet = true; file = UiUtilities::GetFileFromPath(path) ; } std::string pathLabel( property->GetName() + " texture: "); AddReadOnlyString(pathLabel+file, groupParam ); //Add select texture button std::string selectButtonLabel( "Select " + property->GetName() + " texture..."); UiButton* selectTexture = new UiButton(selectButtonLabel, CreateTextureCallback, property); selectTexture->SetLabel(selectButtonLabel); selectTexture->SetGroup(group); m_elementList.push_back( selectTexture ); selectTexture->AddToPanel(*this); //Add clear texture button if ( IsFileSet ) { std::string clearButtonLabel( "Clear " + property->GetName() + " texture" ); UiButton* clearTexture = new UiButton(clearButtonLabel, ClearTextureCallback, property); clearTexture->SetLabel(clearButtonLabel); clearTexture->SetGroup(group); m_elementList.push_back( clearTexture ); clearTexture->AddToPanel(*this); } AddSeparator(groupParam); }
/** * @brief Verify if passing invalid group option to commandline fails * @test Expected result: * - call handler indicates success * - help message in output stream * - error message in error stream */ TEST_F(CynaraCommandlineTest, groupOptionInvalid) { std::string err; std::string out; std::string groupParam("GroupThatDoNotExist"); for (const auto &groupOpt : { "-g", "--group" }) { clearOutput(); prepare_argv({ execName, groupOpt, groupParam}); SCOPED_TRACE(groupOpt); const auto options = Parser::handleCmdlineOptions(this->argc(), this->argv()); getOutput(out, err); ASSERT_TRUE(options.m_error); ASSERT_TRUE(options.m_exit); ASSERT_FALSE(options.m_daemon); ASSERT_EQ(options.m_mask, static_cast<mode_t>(-1)); ASSERT_EQ(options.m_uid, static_cast<uid_t>(-1)); ASSERT_EQ(options.m_gid, static_cast<gid_t>(-1)); ASSERT_EQ(helpMessage, out); ASSERT_EQ("Invalid param: GroupThatDoNotExist\n", err); } }
/** * @brief Verify if passing group option to commandline succeeds * @test Expected result: * - call handler indicates success * - empty output stream * - empty error stream */ TEST_F(CynaraCommandlineTest, groupOptionGid) { std::string err; std::string out; std::string groupParam("1234"); for (const auto &groupOpt : { "-g", "--group" }) { clearOutput(); prepare_argv({ execName, groupOpt, groupParam}); SCOPED_TRACE(groupOpt); const auto options = Parser::handleCmdlineOptions(this->argc(), this->argv()); getOutput(out, err); ASSERT_FALSE(options.m_error); ASSERT_FALSE(options.m_exit); ASSERT_FALSE(options.m_daemon); ASSERT_EQ(options.m_mask, static_cast<mode_t>(-1)); ASSERT_EQ(options.m_uid, static_cast<uid_t>(-1)); ASSERT_EQ(options.m_gid, 1234); ASSERT_TRUE(out.empty()); ASSERT_TRUE(err.empty()); } }
void UiPropertyGrid::SetGroup( SceneManager::Property* property, const std::string& group ) const { std::string groupParam(UI_PARAM_GROUP); property->AddParameter(groupParam + "'" + group + "'" ); }