Can now fully control custom calls from the command line.
Example: out/Debug/vie_auto_test --auto_custom_call --override "Enter destination IP.=127.0.10.55,Enter video send port.=12345" The above will launch a call directly and choose all default values except for the overridden ones specified above. BUG= Review URL: https://webrtc-codereview.appspot.com/920008 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3064 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
2a749d3108
commit
1401285fe7
@ -17,15 +17,16 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
ChoiceBuilder::ChoiceBuilder(const Choices& choices)
|
ChoiceBuilder::ChoiceBuilder(const std::string& title, const Choices& choices)
|
||||||
: choices_(choices),
|
: choices_(choices),
|
||||||
input_helper_(new IntegerWithinRangeValidator(1, choices.size())) {
|
input_helper_(TypedInput(title)) {
|
||||||
|
input_helper_.WithInputValidator(
|
||||||
|
new IntegerWithinRangeValidator(1, choices.size()));
|
||||||
|
input_helper_.WithAdditionalInfo(MakeHumanReadableOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
int ChoiceBuilder::Choose() {
|
int ChoiceBuilder::Choose() {
|
||||||
std::string input = input_helper_
|
std::string input = input_helper_.AskForInput();
|
||||||
.WithTitle(MakeTitleWithOptions())
|
|
||||||
.AskForInput();
|
|
||||||
return atoi(input.c_str());
|
return atoi(input.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,43 +49,24 @@ ChoiceBuilder& ChoiceBuilder::WithInputSource(FILE* input_source) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChoiceBuilder& ChoiceBuilder::WithTitle(const std::string& title) {
|
std::string ChoiceBuilder::MakeHumanReadableOptions() {
|
||||||
title_ = title;
|
std::string result = "";
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ChoiceBuilder::MakeTitleWithOptions() {
|
|
||||||
std::string title_with_options = title_;
|
|
||||||
Choices::const_iterator iterator = choices_.begin();
|
Choices::const_iterator iterator = choices_.begin();
|
||||||
for (int number = 1; iterator != choices_.end(); ++iterator, ++number) {
|
for (int number = 1; iterator != choices_.end(); ++iterator, ++number) {
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
sprintf(buffer, "\n %d. ", number);
|
sprintf(buffer, "\n %d. %s", number, (*iterator).c_str());
|
||||||
title_with_options += buffer;
|
result += buffer;
|
||||||
title_with_options += (*iterator);
|
|
||||||
}
|
}
|
||||||
return title_with_options;
|
|
||||||
}
|
|
||||||
|
|
||||||
Choices SplitChoices(const std::string& raw_choices) {
|
|
||||||
Choices result;
|
|
||||||
size_t current_pos = 0;
|
|
||||||
size_t next_newline = 0;
|
|
||||||
while ((next_newline = raw_choices.find('\n', current_pos)) !=
|
|
||||||
std::string::npos) {
|
|
||||||
std::string choice = raw_choices.substr(
|
|
||||||
current_pos, next_newline - current_pos);
|
|
||||||
result.push_back(choice);
|
|
||||||
current_pos = next_newline + 1;
|
|
||||||
}
|
|
||||||
std::string last_choice = raw_choices.substr(current_pos);
|
|
||||||
if (!last_choice.empty())
|
|
||||||
result.push_back(last_choice);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChoiceBuilder FromChoices(const std::string& raw_choices) {
|
Choices SplitChoices(const std::string& raw_choices) {
|
||||||
return ChoiceBuilder(SplitChoices(raw_choices));
|
return Split(raw_choices, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
ChoiceBuilder FromChoices(
|
||||||
|
const std::string& title, const std::string& raw_choices) {
|
||||||
|
return ChoiceBuilder(title, SplitChoices(raw_choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -38,7 +38,7 @@ typedef std::vector<std::string> Choices;
|
|||||||
*/
|
*/
|
||||||
class ChoiceBuilder {
|
class ChoiceBuilder {
|
||||||
public:
|
public:
|
||||||
explicit ChoiceBuilder(const Choices& choices);
|
explicit ChoiceBuilder(const std::string& title, const Choices& choices);
|
||||||
|
|
||||||
// Specifies the choice as the default. The choice must be one of the choices
|
// Specifies the choice as the default. The choice must be one of the choices
|
||||||
// passed in the constructor. If this method is not called, the user has to
|
// passed in the constructor. If this method is not called, the user has to
|
||||||
@ -48,23 +48,20 @@ class ChoiceBuilder {
|
|||||||
// Replaces the input source where we ask for input. Default is stdin.
|
// Replaces the input source where we ask for input. Default is stdin.
|
||||||
ChoiceBuilder& WithInputSource(FILE* input_source);
|
ChoiceBuilder& WithInputSource(FILE* input_source);
|
||||||
|
|
||||||
// Prints a title above the choice list when the choice is made.
|
|
||||||
ChoiceBuilder& WithTitle(const std::string& title);
|
|
||||||
|
|
||||||
// Prints the choice list and requests input from the input source. Returns
|
// Prints the choice list and requests input from the input source. Returns
|
||||||
// the choice number (choices start at 1).
|
// the choice number (choices start at 1).
|
||||||
int Choose();
|
int Choose();
|
||||||
private:
|
private:
|
||||||
std::string MakeTitleWithOptions();
|
std::string MakeHumanReadableOptions();
|
||||||
|
|
||||||
Choices choices_;
|
Choices choices_;
|
||||||
InputBuilder input_helper_;
|
InputBuilder input_helper_;
|
||||||
std::string title_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convenience function that creates a choice builder given a string where
|
// Convenience function that creates a choice builder given a string where
|
||||||
// choices are separated by \n.
|
// choices are separated by \n.
|
||||||
ChoiceBuilder FromChoices(const std::string& raw_choices);
|
ChoiceBuilder FromChoices(const std::string& title,
|
||||||
|
const std::string& raw_choices);
|
||||||
|
|
||||||
// Creates choices from a string where choices are separated by \n.
|
// Creates choices from a string where choices are separated by \n.
|
||||||
Choices SplitChoices(const std::string& raw_choices);
|
Choices SplitChoices(const std::string& raw_choices);
|
||||||
|
@ -59,32 +59,36 @@ TEST_F(ChoiceHelpersTest, SplitHandlesMultipleChoicesWithEndingNewline) {
|
|||||||
|
|
||||||
TEST_F(ChoiceHelpersTest, CanSelectUsingChoiceBuilder) {
|
TEST_F(ChoiceHelpersTest, CanSelectUsingChoiceBuilder) {
|
||||||
FILE* fake_stdin = FakeStdin("1\n2\n");
|
FILE* fake_stdin = FakeStdin("1\n2\n");
|
||||||
EXPECT_EQ(1, FromChoices("Choice 1\n"
|
EXPECT_EQ(1, FromChoices("Title",
|
||||||
|
"Choice 1\n"
|
||||||
"Choice 2").WithInputSource(fake_stdin).Choose());
|
"Choice 2").WithInputSource(fake_stdin).Choose());
|
||||||
EXPECT_EQ(2, FromChoices("Choice 1\n"
|
EXPECT_EQ(2, FromChoices("","Choice 1\n"
|
||||||
"Choice 2").WithInputSource(fake_stdin).Choose());
|
"Choice 2").WithInputSource(fake_stdin).Choose());
|
||||||
fclose(fake_stdin);
|
fclose(fake_stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ChoiceHelpersTest, RetriesIfGivenInvalidChoice) {
|
TEST_F(ChoiceHelpersTest, RetriesIfGivenInvalidChoice) {
|
||||||
FILE* fake_stdin = FakeStdin("3\n0\n99\n23409234809\na\nwhatever\n1\n");
|
FILE* fake_stdin = FakeStdin("3\n0\n99\n23409234809\na\nwhatever\n1\n");
|
||||||
EXPECT_EQ(1, FromChoices("Choice 1\n"
|
EXPECT_EQ(1, FromChoices("Title",
|
||||||
|
"Choice 1\n"
|
||||||
"Choice 2").WithInputSource(fake_stdin).Choose());
|
"Choice 2").WithInputSource(fake_stdin).Choose());
|
||||||
fclose(fake_stdin);
|
fclose(fake_stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ChoiceHelpersTest, RetriesOnEnterIfNoDefaultSet) {
|
TEST_F(ChoiceHelpersTest, RetriesOnEnterIfNoDefaultSet) {
|
||||||
FILE* fake_stdin = FakeStdin("\n2\n");
|
FILE* fake_stdin = FakeStdin("\n2\n");
|
||||||
EXPECT_EQ(2, FromChoices("Choice 1\n"
|
EXPECT_EQ(2, FromChoices("Title",
|
||||||
|
"Choice 1\n"
|
||||||
"Choice 2").WithInputSource(fake_stdin).Choose());
|
"Choice 2").WithInputSource(fake_stdin).Choose());
|
||||||
fclose(fake_stdin);
|
fclose(fake_stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ChoiceHelpersTest, PicksDefaultOnEnterIfDefaultSet) {
|
TEST_F(ChoiceHelpersTest, PicksDefaultOnEnterIfDefaultSet) {
|
||||||
FILE* fake_stdin = FakeStdin("\n");
|
FILE* fake_stdin = FakeStdin("\n");
|
||||||
EXPECT_EQ(2, FromChoices("Choice 1\n"
|
EXPECT_EQ(2, FromChoices("Title",
|
||||||
|
"Choice 1\n"
|
||||||
"Choice 2").WithInputSource(fake_stdin)
|
"Choice 2").WithInputSource(fake_stdin)
|
||||||
.WithDefault("Choice 2").Choose());
|
.WithDefault("Choice 2").Choose());
|
||||||
fclose(fake_stdin);
|
fclose(fake_stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,14 +13,22 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "gflags/gflags.h"
|
#include "gflags/gflags.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
DEFINE_bool(choose_defaults, false,
|
DEFINE_string(override, "",
|
||||||
"Make the default choice at every choice when running a custom call.");
|
"Makes it possible to override choices or inputs. All choices and "
|
||||||
|
"inputs will use their default values unless you override them in this "
|
||||||
|
"flag's argument. There can be several comma-separated overrides specified:"
|
||||||
|
" Overrides are specified as \"title=option text\" for choices and "
|
||||||
|
"\"title=value\" for regular inputs. Note that the program will stop if "
|
||||||
|
"you provide input not accepted by the input's validator through this flag."
|
||||||
|
"\n\nExample: --override \"Enter destination IP=192.168.0.1, "
|
||||||
|
"Select a codec=VP8\"");
|
||||||
|
|
||||||
class AcceptAllNonEmptyValidator : public InputValidator {
|
class AcceptAllNonEmptyValidator : public InputValidator {
|
||||||
public:
|
public:
|
||||||
@ -29,9 +37,11 @@ class AcceptAllNonEmptyValidator : public InputValidator {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
InputBuilder::InputBuilder(const InputValidator* input_validator)
|
InputBuilder::InputBuilder(const std::string& title,
|
||||||
|
const InputValidator* input_validator,
|
||||||
|
const OverrideRegistry& override_registry)
|
||||||
: input_source_(stdin), input_validator_(input_validator),
|
: input_source_(stdin), input_validator_(input_validator),
|
||||||
default_value_("") {
|
override_registry_(override_registry), default_value_(""), title_(title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
InputBuilder::~InputBuilder() {
|
InputBuilder::~InputBuilder() {
|
||||||
@ -39,10 +49,17 @@ InputBuilder::~InputBuilder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string InputBuilder::AskForInput() const {
|
std::string InputBuilder::AskForInput() const {
|
||||||
if (FLAGS_choose_defaults && !default_value_.empty())
|
if (override_registry_.HasOverrideFor(title_))
|
||||||
|
return GetOverride();
|
||||||
|
if (!FLAGS_override.empty() && !default_value_.empty())
|
||||||
return default_value_;
|
return default_value_;
|
||||||
if (!title_.empty())
|
|
||||||
printf("\n%s\n", title_.c_str());
|
// We don't know the answer already, so ask the user.
|
||||||
|
return ActuallyAskUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string InputBuilder::ActuallyAskUser() const {
|
||||||
|
printf("\n%s%s\n", title_.c_str(), additional_info_.c_str());
|
||||||
|
|
||||||
if (!default_value_.empty())
|
if (!default_value_.empty())
|
||||||
printf("Hit enter for default (%s):\n", default_value_.c_str());
|
printf("Hit enter for default (%s):\n", default_value_.c_str());
|
||||||
@ -62,7 +79,7 @@ std::string InputBuilder::AskForInput() const {
|
|||||||
|
|
||||||
if (!input_validator_->InputOk(input)) {
|
if (!input_validator_->InputOk(input)) {
|
||||||
printf("Invalid input. Please try again.\n");
|
printf("Invalid input. Please try again.\n");
|
||||||
return AskForInput();
|
return ActuallyAskUser();
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
@ -87,13 +104,69 @@ InputBuilder& InputBuilder::WithDefault(const std::string& default_value) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputBuilder& InputBuilder::WithTitle(const std::string& title) {
|
InputBuilder& InputBuilder::WithAdditionalInfo(const std::string& info) {
|
||||||
title_ = title;
|
additional_info_ = info;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputBuilder TypedInput() {
|
const std::string& InputBuilder::GetOverride() const {
|
||||||
return InputBuilder(new AcceptAllNonEmptyValidator());
|
const std::string& override = override_registry_.GetOverrideFor(title_);
|
||||||
|
if (!input_validator_->InputOk(override)) {
|
||||||
|
printf("Fatal: Input validator for \"%s\" does not accept override %s.\n",
|
||||||
|
title_.c_str(), override.c_str());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return override;
|
||||||
|
}
|
||||||
|
|
||||||
|
OverrideRegistry::OverrideRegistry(const std::string& overrides) {
|
||||||
|
std::vector<std::string> all_overrides = Split(overrides, ",");
|
||||||
|
std::vector<std::string>::const_iterator override = all_overrides.begin();
|
||||||
|
for (; override != all_overrides.end(); ++override) {
|
||||||
|
std::vector<std::string> key_value = Split(*override, "=");
|
||||||
|
if (key_value.size() != 2) {
|
||||||
|
printf("Fatal: Override %s is malformed.", (*override).c_str());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
std::string key = key_value[0];
|
||||||
|
std::string value = key_value[1];
|
||||||
|
overrides_[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OverrideRegistry::HasOverrideFor(const std::string& title) const {
|
||||||
|
return overrides_.find(title) != overrides_.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& OverrideRegistry::GetOverrideFor(
|
||||||
|
const std::string& title) const {
|
||||||
|
assert(HasOverrideFor(title));
|
||||||
|
return (*overrides_.find(title)).second;
|
||||||
|
}
|
||||||
|
|
||||||
|
InputBuilder TypedInput(const std::string& title) {
|
||||||
|
static OverrideRegistry override_registry_(FLAGS_override);
|
||||||
|
return InputBuilder(
|
||||||
|
title, new AcceptAllNonEmptyValidator(), override_registry_);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> Split(const std::string& to_split,
|
||||||
|
const std::string& delimiter) {
|
||||||
|
std::vector<std::string> result;
|
||||||
|
size_t current_pos = 0;
|
||||||
|
size_t next_delimiter = 0;
|
||||||
|
while ((next_delimiter = to_split.find(delimiter, current_pos)) !=
|
||||||
|
std::string::npos) {
|
||||||
|
std::string part = to_split.substr(
|
||||||
|
current_pos, next_delimiter - current_pos);
|
||||||
|
result.push_back(part);
|
||||||
|
current_pos = next_delimiter + 1;
|
||||||
|
}
|
||||||
|
std::string last_part = to_split.substr(current_pos);
|
||||||
|
if (!last_part.empty())
|
||||||
|
result.push_back(last_part);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -13,46 +13,77 @@
|
|||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "gflags/gflags.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class InputValidator {
|
class InputValidator;
|
||||||
public:
|
class OverrideRegistry;
|
||||||
virtual ~InputValidator() {}
|
|
||||||
|
|
||||||
virtual bool InputOk(const std::string& value) const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// This class handles general user input to the application.
|
||||||
class InputBuilder {
|
class InputBuilder {
|
||||||
public:
|
public:
|
||||||
// The input builder takes ownership of the validator.
|
// The input builder takes ownership of the validator (but not the
|
||||||
explicit InputBuilder(const InputValidator* input_validator);
|
// override registry).
|
||||||
|
InputBuilder(const std::string& title,
|
||||||
|
const InputValidator* input_validator,
|
||||||
|
const OverrideRegistry& override_registry);
|
||||||
~InputBuilder();
|
~InputBuilder();
|
||||||
|
|
||||||
// Ask the user for input, reads input from the input source and returns
|
// Ask the user for input, reads input from the input source and returns
|
||||||
// the answer. This method will keep asking the user until a correct answer
|
// the answer. This method will keep asking the user until a correct answer
|
||||||
// is returned and is thereby guaranteed to return a response that is
|
// is returned and is thereby guaranteed to return a response that is
|
||||||
// acceptable to the input validator.
|
// acceptable to the input validator.
|
||||||
|
//
|
||||||
|
// In some cases we will not actually ask the user for input, for instance
|
||||||
|
// if the --choose-defaults or --override flags are specified. See the
|
||||||
|
// definition of those flags in the .cc file for more information.
|
||||||
std::string AskForInput() const;
|
std::string AskForInput() const;
|
||||||
|
|
||||||
// Replaces the input source where we ask for input. Default is stdin.
|
// Replaces the input source where we ask for input. Default is stdin.
|
||||||
InputBuilder& WithInputSource(FILE* input_source);
|
InputBuilder& WithInputSource(FILE* input_source);
|
||||||
|
|
||||||
// Sets the input validator. The input builder takes ownership. If a default
|
// Sets the input validator. The input builder takes ownership. If a default
|
||||||
// value has been set, it must be acceptable to this validator.
|
// value has been set, it must be acceptable to this validator.
|
||||||
InputBuilder& WithInputValidator(const InputValidator* input_validator);
|
InputBuilder& WithInputValidator(const InputValidator* input_validator);
|
||||||
// Sets a default value if the user doesn't want to give input. This value
|
// Sets a default value if the user doesn't want to give input. This value
|
||||||
// must be acceptable to the input validator.
|
// must be acceptable to the input validator.
|
||||||
InputBuilder& WithDefault(const std::string& default_value);
|
InputBuilder& WithDefault(const std::string& default_value);
|
||||||
// Prints a title before querying the user.
|
// Prints additional info after the title.
|
||||||
InputBuilder& WithTitle(const std::string& title);
|
InputBuilder& WithAdditionalInfo(const std::string& title);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const std::string& GetOverride() const;
|
||||||
|
std::string ActuallyAskUser() const;
|
||||||
|
|
||||||
FILE* input_source_;
|
FILE* input_source_;
|
||||||
const InputValidator* input_validator_;
|
const InputValidator* input_validator_;
|
||||||
|
const OverrideRegistry& override_registry_;
|
||||||
std::string default_value_;
|
std::string default_value_;
|
||||||
std::string title_;
|
std::string title_;
|
||||||
|
std::string additional_info_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Keeps track of overrides for any input points. Overrides are passed in the
|
||||||
|
// format Title 1=Value 1,Title 2=Value 2. Spaces are not trimmed anywhere.
|
||||||
|
class OverrideRegistry {
|
||||||
|
public:
|
||||||
|
OverrideRegistry(const std::string& overrides);
|
||||||
|
bool HasOverrideFor(const std::string& title) const;
|
||||||
|
const std::string& GetOverrideFor(const std::string& title) const;
|
||||||
|
private:
|
||||||
|
typedef std::map<std::string, std::string> OverrideMap;
|
||||||
|
OverrideMap overrides_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class InputValidator {
|
||||||
|
public:
|
||||||
|
virtual ~InputValidator() {}
|
||||||
|
|
||||||
|
virtual bool InputOk(const std::string& value) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ensures input is an integer between low and high (inclusive).
|
// Ensures input is an integer between low and high (inclusive).
|
||||||
@ -74,8 +105,11 @@ class IntegerWithinRangeValidator : public InputValidator {
|
|||||||
int high_;
|
int high_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::vector<std::string> Split(const std::string& to_split,
|
||||||
|
const std::string& delimiter);
|
||||||
|
|
||||||
// Convenience method for creating an input builder.
|
// Convenience method for creating an input builder.
|
||||||
InputBuilder TypedInput();
|
InputBuilder TypedInput(const std::string& title);
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
|
@ -19,14 +19,15 @@ class InputHelpersTest: public testing::Test {
|
|||||||
|
|
||||||
TEST_F(InputHelpersTest, AcceptsAnyInputExceptEmptyByDefault) {
|
TEST_F(InputHelpersTest, AcceptsAnyInputExceptEmptyByDefault) {
|
||||||
FILE* fake_stdin = FakeStdin("\n\nWhatever\n");
|
FILE* fake_stdin = FakeStdin("\n\nWhatever\n");
|
||||||
std::string result = TypedInput().WithInputSource(fake_stdin).AskForInput();
|
std::string result = TypedInput("Title")
|
||||||
|
.WithInputSource(fake_stdin).AskForInput();
|
||||||
EXPECT_EQ("Whatever", result);
|
EXPECT_EQ("Whatever", result);
|
||||||
fclose(fake_stdin);
|
fclose(fake_stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InputHelpersTest, ReturnsDefaultOnEmptyInputIfDefaultSet) {
|
TEST_F(InputHelpersTest, ReturnsDefaultOnEmptyInputIfDefaultSet) {
|
||||||
FILE* fake_stdin = FakeStdin("\n\nWhatever\n");
|
FILE* fake_stdin = FakeStdin("\n\nWhatever\n");
|
||||||
std::string result = TypedInput()
|
std::string result = TypedInput("Title")
|
||||||
.WithInputSource(fake_stdin)
|
.WithInputSource(fake_stdin)
|
||||||
.WithDefault("MyDefault")
|
.WithDefault("MyDefault")
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
@ -34,16 +35,6 @@ TEST_F(InputHelpersTest, ReturnsDefaultOnEmptyInputIfDefaultSet) {
|
|||||||
fclose(fake_stdin);
|
fclose(fake_stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InputHelpersTest, CanSetTitle) {
|
|
||||||
FILE* fake_stdin = FakeStdin("\n\nWhatever\n");
|
|
||||||
std::string result = TypedInput()
|
|
||||||
.WithInputSource(fake_stdin)
|
|
||||||
.WithTitle("Make a choice!")
|
|
||||||
.AskForInput();
|
|
||||||
EXPECT_EQ("Whatever", result);
|
|
||||||
fclose(fake_stdin);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(InputHelpersTest, ObeysInputValidator) {
|
TEST_F(InputHelpersTest, ObeysInputValidator) {
|
||||||
class ValidatorWhichOnlyAcceptsFooBar : public InputValidator {
|
class ValidatorWhichOnlyAcceptsFooBar : public InputValidator {
|
||||||
public:
|
public:
|
||||||
@ -52,11 +43,38 @@ TEST_F(InputHelpersTest, ObeysInputValidator) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
FILE* fake_stdin = FakeStdin("\nFoo\nBar\nFoo Bar\nFooBar\n");
|
FILE* fake_stdin = FakeStdin("\nFoo\nBar\nFoo Bar\nFooBar\n");
|
||||||
std::string result = TypedInput()
|
std::string result = TypedInput("Title")
|
||||||
.WithInputSource(fake_stdin)
|
.WithInputSource(fake_stdin)
|
||||||
.WithInputValidator(new ValidatorWhichOnlyAcceptsFooBar())
|
.WithInputValidator(new ValidatorWhichOnlyAcceptsFooBar())
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
EXPECT_EQ("FooBar", result);
|
EXPECT_EQ("FooBar", result);
|
||||||
fclose(fake_stdin);
|
fclose(fake_stdin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(InputHelpersTest, OverrideRegistryParsesOverridesCorrectly) {
|
||||||
|
// TODO(phoglund): Ignore spaces where appropriate
|
||||||
|
OverrideRegistry override_registry("My Title=Value,My Choice=1");
|
||||||
|
EXPECT_TRUE(override_registry.HasOverrideFor("My Title"));
|
||||||
|
EXPECT_EQ("Value", override_registry.GetOverrideFor("My Title"));
|
||||||
|
EXPECT_TRUE(override_registry.HasOverrideFor("My Choice"));
|
||||||
|
EXPECT_EQ("1", override_registry.GetOverrideFor("My Choice"));
|
||||||
|
EXPECT_FALSE(override_registry.HasOverrideFor("Not Overridden"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(InputHelpersTest, ObeysOverridesBeforeAnythingElse) {
|
||||||
|
class CarelessValidator : public InputValidator {
|
||||||
|
public:
|
||||||
|
bool InputOk(const std::string& input) const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FILE* fake_stdin = FakeStdin("\nFoo\nBar\nFoo Bar\nFooBar\n");
|
||||||
|
OverrideRegistry override_registry("My Title=Value,My Choice=1");
|
||||||
|
EXPECT_EQ("Value", InputBuilder("My Title",
|
||||||
|
new CarelessValidator(), override_registry)
|
||||||
|
.WithDefault("Whatever")
|
||||||
|
.WithInputSource(fake_stdin).AskForInput());
|
||||||
|
fclose(fake_stdin);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -315,7 +315,8 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
int selection =
|
int selection =
|
||||||
FromChoices("Start the call\n"
|
FromChoices("Ready to start:",
|
||||||
|
"Start the call\n"
|
||||||
"Reconfigure call settings\n")
|
"Reconfigure call settings\n")
|
||||||
.WithDefault("Start the call").Choose();
|
.WithDefault("Start the call").Choose();
|
||||||
start_call = (selection == 1);
|
start_call = (selection == 1);
|
||||||
@ -521,6 +522,7 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
// Modify call or stop call.
|
// Modify call or stop call.
|
||||||
printf("\n");
|
printf("\n");
|
||||||
int selection = FromChoices(
|
int selection = FromChoices(
|
||||||
|
"And now?",
|
||||||
"Stop the call\n"
|
"Stop the call\n"
|
||||||
"Modify the call\n").Choose();
|
"Modify the call\n").Choose();
|
||||||
|
|
||||||
@ -529,6 +531,7 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
while (selection == 2) {
|
while (selection == 2) {
|
||||||
// Keep on modifying the call until user stops the call.
|
// Keep on modifying the call until user stops the call.
|
||||||
int modify_selection = FromChoices(
|
int modify_selection = FromChoices(
|
||||||
|
"Modify the call:",
|
||||||
"Stop call\n"
|
"Stop call\n"
|
||||||
"Change Video Send Codec\n"
|
"Change Video Send Codec\n"
|
||||||
"Change Video Send Size by Common Resolutions\n"
|
"Change Video Send Size by Common Resolutions\n"
|
||||||
@ -545,7 +548,6 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
"Print Call Statistics\n"
|
"Print Call Statistics\n"
|
||||||
"Toggle Image Scaling (Warning: high CPU usage when enabled)\n")
|
"Toggle Image Scaling (Warning: high CPU usage when enabled)\n")
|
||||||
.WithDefault("Stop call")
|
.WithDefault("Stop call")
|
||||||
.WithTitle("Modify the call:")
|
|
||||||
.Choose();
|
.Choose();
|
||||||
|
|
||||||
switch (modify_selection) {
|
switch (modify_selection) {
|
||||||
@ -696,6 +698,7 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
case 8:
|
case 8:
|
||||||
// Send the file on the video_channel.
|
// Send the file on the video_channel.
|
||||||
file_selection = FromChoices(
|
file_selection = FromChoices(
|
||||||
|
"Choose a file name:",
|
||||||
DEFAULT_INCOMING_FILE_NAME "\n"
|
DEFAULT_INCOMING_FILE_NAME "\n"
|
||||||
DEFAULT_OUTGOING_FILE_NAME "\n")
|
DEFAULT_OUTGOING_FILE_NAME "\n")
|
||||||
.WithDefault(DEFAULT_INCOMING_FILE_NAME).Choose();
|
.WithDefault(DEFAULT_INCOMING_FILE_NAME).Choose();
|
||||||
@ -1016,9 +1019,8 @@ bool GetVideoDevice(webrtc::ViEBase* vie_base,
|
|||||||
first_device = capture_line;
|
first_device = capture_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
int choice = FromChoices(capture_choices)
|
int choice = FromChoices("Available Video Capture Devices", capture_choices)
|
||||||
.WithDefault(first_device)
|
.WithDefault(first_device)
|
||||||
.WithTitle("Available Video Capture Devices")
|
|
||||||
.Choose();
|
.Choose();
|
||||||
|
|
||||||
error = vie_capture->GetCaptureDevice(
|
error = vie_capture->GetCaptureDevice(
|
||||||
@ -1069,9 +1071,8 @@ bool GetAudioDevices(webrtc::VoEBase* voe_base,
|
|||||||
default_recording_line = recording_device_name;
|
default_recording_line = recording_device_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int choice = FromChoices(device_choices)
|
int choice = FromChoices("Available audio capture devices:", device_choices)
|
||||||
.WithDefault(default_recording_line)
|
.WithDefault(default_recording_line)
|
||||||
.WithTitle("Available audio capture devices:")
|
|
||||||
.Choose();
|
.Choose();
|
||||||
|
|
||||||
recording_device_index = choice - 1;
|
recording_device_index = choice - 1;
|
||||||
@ -1101,9 +1102,8 @@ bool GetAudioDevices(webrtc::VoEBase* voe_base,
|
|||||||
default_playback_line = playback_device_name;
|
default_playback_line = playback_device_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
choice = FromChoices(playback_choices)
|
choice = FromChoices("Available audio playout devices:", playback_choices)
|
||||||
.WithDefault(default_playback_line)
|
.WithDefault(default_playback_line)
|
||||||
.WithTitle("Available audio playout devices:")
|
|
||||||
.Choose();
|
.Choose();
|
||||||
|
|
||||||
playback_device_index = choice - 1;
|
playback_device_index = choice - 1;
|
||||||
@ -1126,9 +1126,8 @@ std::string GetIPAddress() {
|
|||||||
return std::count(input.begin(), input.end(), '.') == 3;
|
return std::count(input.begin(), input.end(), '.') == 3;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return TypedInput()
|
return TypedInput("Enter destination IP.")
|
||||||
.WithDefault(DEFAULT_SEND_IP)
|
.WithDefault(DEFAULT_SEND_IP)
|
||||||
.WithTitle("Enter destination IP.")
|
|
||||||
.WithInputValidator(new IpValidator())
|
.WithInputValidator(new IpValidator())
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
}
|
}
|
||||||
@ -1136,15 +1135,13 @@ std::string GetIPAddress() {
|
|||||||
// Video settings functions.
|
// Video settings functions.
|
||||||
|
|
||||||
void GetVideoPorts(int* tx_port, int* rx_port) {
|
void GetVideoPorts(int* tx_port, int* rx_port) {
|
||||||
std::string tx_input = TypedInput()
|
std::string tx_input = TypedInput("Enter video send port.")
|
||||||
.WithTitle("Enter video send port.")
|
|
||||||
.WithDefault(DEFAULT_VIDEO_PORT)
|
.WithDefault(DEFAULT_VIDEO_PORT)
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
*tx_port = atoi(tx_input.c_str());
|
*tx_port = atoi(tx_input.c_str());
|
||||||
|
|
||||||
std::string rx_input = TypedInput()
|
std::string rx_input = TypedInput("Enter video receive port.")
|
||||||
.WithTitle("Enter video receive port.")
|
|
||||||
.WithDefault(DEFAULT_VIDEO_PORT)
|
.WithDefault(DEFAULT_VIDEO_PORT)
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
@ -1154,15 +1151,13 @@ void GetVideoPorts(int* tx_port, int* rx_port) {
|
|||||||
// Audio settings functions.
|
// Audio settings functions.
|
||||||
|
|
||||||
void GetAudioPorts(int* tx_port, int* rx_port) {
|
void GetAudioPorts(int* tx_port, int* rx_port) {
|
||||||
std::string tx_input = TypedInput()
|
std::string tx_input = TypedInput("Enter audio send port.")
|
||||||
.WithTitle("Enter audio send port.")
|
|
||||||
.WithDefault(DEFAULT_AUDIO_PORT)
|
.WithDefault(DEFAULT_AUDIO_PORT)
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
*tx_port = atoi(tx_input.c_str());
|
*tx_port = atoi(tx_input.c_str());
|
||||||
|
|
||||||
std::string rx_input = TypedInput()
|
std::string rx_input = TypedInput("Enter audio receive port.")
|
||||||
.WithTitle("Enter audio receive port.")
|
|
||||||
.WithDefault(DEFAULT_AUDIO_PORT)
|
.WithDefault(DEFAULT_AUDIO_PORT)
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
@ -1195,9 +1190,8 @@ bool GetAudioCodec(webrtc::VoECodec* voe_codec,
|
|||||||
}
|
}
|
||||||
assert(!default_codec_line.empty() && "Default codec doesn't exist.");
|
assert(!default_codec_line.empty() && "Default codec doesn't exist.");
|
||||||
|
|
||||||
int codec_selection = FromChoices(codec_choices)
|
int codec_selection = FromChoices("Available Audio Codecs:", codec_choices)
|
||||||
.WithDefault(default_codec_line)
|
.WithDefault(default_codec_line)
|
||||||
.WithTitle("Available Audio Codecs:")
|
|
||||||
.Choose();
|
.Choose();
|
||||||
|
|
||||||
error = voe_codec->GetCodec(codec_selection - 1, audio_codec);
|
error = voe_codec->GetCodec(codec_selection - 1, audio_codec);
|
||||||
@ -1265,9 +1259,8 @@ void SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
|||||||
}
|
}
|
||||||
assert(!default_codec_line.empty() && "Default does not exist.");
|
assert(!default_codec_line.empty() && "Default does not exist.");
|
||||||
|
|
||||||
int choice = FromChoices(codec_choices)
|
int choice = FromChoices("Available Video Codecs", codec_choices)
|
||||||
.WithDefault(default_codec_line)
|
.WithDefault(default_codec_line)
|
||||||
.WithTitle("Available Video Codecs")
|
|
||||||
.Choose();
|
.Choose();
|
||||||
error = vie_codec->GetCodec(choice - 1, *video_codec);
|
error = vie_codec->GetCodec(choice - 1, *video_codec);
|
||||||
number_of_errors += ViETest::TestError(
|
number_of_errors += ViETest::TestError(
|
||||||
@ -1286,6 +1279,7 @@ void SetVideoCodecResolution(webrtc::VideoCodec* video_codec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int choice = FromChoices(
|
int choice = FromChoices(
|
||||||
|
"Available Common Resolutions:",
|
||||||
"SQCIF (128X96)\n"
|
"SQCIF (128X96)\n"
|
||||||
"QQVGA (160X120)\n"
|
"QQVGA (160X120)\n"
|
||||||
"QCIF (176X144)\n"
|
"QCIF (176X144)\n"
|
||||||
@ -1296,7 +1290,6 @@ void SetVideoCodecResolution(webrtc::VideoCodec* video_codec) {
|
|||||||
"SVGA (800X600)\n"
|
"SVGA (800X600)\n"
|
||||||
"HD (1280X720)\n"
|
"HD (1280X720)\n"
|
||||||
"XGA (1024x768)\n")
|
"XGA (1024x768)\n")
|
||||||
.WithTitle("Available Common Resolutions:")
|
|
||||||
.Choose();
|
.Choose();
|
||||||
|
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
@ -1349,25 +1342,22 @@ void SetVideoCodecSize(webrtc::VideoCodec* video_codec) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string input = TypedInput()
|
std::string input = TypedInput("Choose video width.")
|
||||||
.WithDefault(DEFAULT_VIDEO_CODEC_WIDTH)
|
.WithDefault(DEFAULT_VIDEO_CODEC_WIDTH)
|
||||||
.WithTitle("Choose video width.")
|
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
video_codec->width = atoi(input.c_str());
|
video_codec->width = atoi(input.c_str());
|
||||||
|
|
||||||
input = TypedInput()
|
input = TypedInput("Choose video height.")
|
||||||
.WithDefault(DEFAULT_VIDEO_CODEC_HEIGHT)
|
.WithDefault(DEFAULT_VIDEO_CODEC_HEIGHT)
|
||||||
.WithTitle("Choose video height.")
|
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
video_codec->height = atoi(input.c_str());
|
video_codec->height = atoi(input.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetVideoCodecBitrate(webrtc::VideoCodec* video_codec) {
|
void SetVideoCodecBitrate(webrtc::VideoCodec* video_codec) {
|
||||||
std::string input = TypedInput()
|
std::string input = TypedInput("Choose start rate (in kbps).")
|
||||||
.WithDefault(DEFAULT_VIDEO_CODEC_BITRATE)
|
.WithDefault(DEFAULT_VIDEO_CODEC_BITRATE)
|
||||||
.WithTitle("Choose start rate (in kbps).")
|
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
|
|
||||||
@ -1375,9 +1365,8 @@ void SetVideoCodecBitrate(webrtc::VideoCodec* video_codec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetVideoCodecMaxBitrate(webrtc::VideoCodec* video_codec) {
|
void SetVideoCodecMaxBitrate(webrtc::VideoCodec* video_codec) {
|
||||||
std::string input = TypedInput()
|
std::string input = TypedInput("Choose max bitrate (in kbps).")
|
||||||
.WithDefault(DEFAULT_VIDEO_CODEC_MAX_BITRATE)
|
.WithDefault(DEFAULT_VIDEO_CODEC_MAX_BITRATE)
|
||||||
.WithTitle("Choose max bitrate (in kbps).")
|
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
|
|
||||||
@ -1385,9 +1374,8 @@ void SetVideoCodecMaxBitrate(webrtc::VideoCodec* video_codec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetVideoCodecMinBitrate(webrtc::VideoCodec* video_codec) {
|
void SetVideoCodecMinBitrate(webrtc::VideoCodec* video_codec) {
|
||||||
std::string input = TypedInput()
|
std::string input = TypedInput("Choose min bitrate (in kbps).")
|
||||||
.WithDefault(DEFAULT_VIDEO_CODEC_MIN_BITRATE)
|
.WithDefault(DEFAULT_VIDEO_CODEC_MIN_BITRATE)
|
||||||
.WithTitle("Choose min bitrate (in kbps).")
|
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
|
|
||||||
@ -1395,9 +1383,8 @@ void SetVideoCodecMinBitrate(webrtc::VideoCodec* video_codec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetVideoCodecMaxFramerate(webrtc::VideoCodec* video_codec) {
|
void SetVideoCodecMaxFramerate(webrtc::VideoCodec* video_codec) {
|
||||||
std::string input = TypedInput()
|
std::string input = TypedInput("Choose max framerate (in fps).")
|
||||||
.WithDefault(DEFAULT_VIDEO_CODEC_MAX_FRAMERATE)
|
.WithDefault(DEFAULT_VIDEO_CODEC_MAX_FRAMERATE)
|
||||||
.WithTitle("Choose max framerate (in fps).")
|
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
video_codec->maxFramerate = atoi(input.c_str());
|
video_codec->maxFramerate = atoi(input.c_str());
|
||||||
@ -1407,9 +1394,8 @@ void SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec) {
|
|||||||
if (video_codec->codecType != webrtc::kVideoCodecVP8)
|
if (video_codec->codecType != webrtc::kVideoCodecVP8)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string input = TypedInput()
|
std::string input = TypedInput("Choose number of temporal layers (0 to 4).")
|
||||||
.WithDefault(DEFAULT_TEMPORAL_LAYER)
|
.WithDefault(DEFAULT_TEMPORAL_LAYER)
|
||||||
.WithTitle("Choose number of temporal layers (0 to 4).")
|
|
||||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(0, 4))
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(0, 4))
|
||||||
.AskForInput();
|
.AskForInput();
|
||||||
video_codec->codecSpecific.VP8.numberOfTemporalLayers = atoi(input.c_str());
|
video_codec->codecSpecific.VP8.numberOfTemporalLayers = atoi(input.c_str());
|
||||||
@ -1419,12 +1405,12 @@ void SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec) {
|
|||||||
// that SetVideoProtection method uses.
|
// that SetVideoProtection method uses.
|
||||||
VideoProtectionMethod GetVideoProtection() {
|
VideoProtectionMethod GetVideoProtection() {
|
||||||
int choice = FromChoices(
|
int choice = FromChoices(
|
||||||
|
"Available Video Protection Methods:",
|
||||||
"None\n"
|
"None\n"
|
||||||
"FEC\n"
|
"FEC\n"
|
||||||
"NACK\n"
|
"NACK\n"
|
||||||
"NACK+FEC\n")
|
"NACK+FEC\n")
|
||||||
.WithDefault(DEFAULT_VIDEO_PROTECTION_METHOD)
|
.WithDefault(DEFAULT_VIDEO_PROTECTION_METHOD)
|
||||||
.WithTitle("Available Video Protection Methods:")
|
|
||||||
.Choose();
|
.Choose();
|
||||||
|
|
||||||
assert(choice >= kProtectionMethodNone &&
|
assert(choice >= kProtectionMethodNone &&
|
||||||
@ -1530,10 +1516,10 @@ bool SetVideoProtection(webrtc::ViECodec* vie_codec,
|
|||||||
// Returns true if REMB, false if TMMBR.
|
// Returns true if REMB, false if TMMBR.
|
||||||
bool GetBitrateSignaling() {
|
bool GetBitrateSignaling() {
|
||||||
int choice = FromChoices(
|
int choice = FromChoices(
|
||||||
|
"Available Bitrate Signaling Methods:",
|
||||||
"REMB\n"
|
"REMB\n"
|
||||||
"TMMBR\n")
|
"TMMBR\n")
|
||||||
.WithDefault("REMB")
|
.WithDefault("REMB")
|
||||||
.WithTitle("Available Bitrate Signaling Methods:")
|
|
||||||
.Choose();
|
.Choose();
|
||||||
return choice == 1;
|
return choice == 1;
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
|
|
||||||
#include "gflags/gflags.h"
|
#include "gflags/gflags.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "vie_autotest.h"
|
#include "video_engine/test/auto_test/interface/vie_autotest.h"
|
||||||
#include "vie_autotest_window_manager_interface.h"
|
#include "video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h"
|
||||||
#include "vie_window_creator.h"
|
#include "video_engine/test/auto_test/interface/vie_window_creator.h"
|
||||||
|
|
||||||
DEFINE_bool(automated, false, "Run Video engine tests in noninteractive mode.");
|
DEFINE_bool(automated, false, "Run Video engine tests in noninteractive mode.");
|
||||||
|
DEFINE_bool(auto_custom_call, false, "Run custom call directly.");
|
||||||
|
|
||||||
static const std::string kStandardTest = "ViEStandardIntegrationTest";
|
static const std::string kStandardTest = "ViEStandardIntegrationTest";
|
||||||
static const std::string kExtendedTest = "ViEExtendedIntegrationTest";
|
static const std::string kExtendedTest = "ViEExtendedIntegrationTest";
|
||||||
@ -46,6 +47,9 @@ int ViEAutoTestMain::RunTests(int argc, char** argv) {
|
|||||||
if (FLAGS_automated) {
|
if (FLAGS_automated) {
|
||||||
// Run in automated mode.
|
// Run in automated mode.
|
||||||
result = RUN_ALL_TESTS();
|
result = RUN_ALL_TESTS();
|
||||||
|
} else if (FLAGS_auto_custom_call) {
|
||||||
|
// Run automated custom call.
|
||||||
|
result = RunSpecialTestCase(8);
|
||||||
} else {
|
} else {
|
||||||
// Run in interactive mode.
|
// Run in interactive mode.
|
||||||
result = RunInteractiveMode();
|
result = RunInteractiveMode();
|
||||||
@ -116,7 +120,7 @@ int ViEAutoTestMain::RunSpecificTestCaseIn(const std::string test_case_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ViEAutoTestMain::RunSpecialTestCase(int choice) {
|
int ViEAutoTestMain::RunSpecialTestCase(int choice) {
|
||||||
// 7-9 don't run in GTest and need to initialize by themselves.
|
// 7-10 don't run in GTest and need to initialize by themselves.
|
||||||
assert(choice >= 7 && choice <= 10);
|
assert(choice >= 7 && choice <= 10);
|
||||||
|
|
||||||
// Create the windows
|
// Create the windows
|
||||||
@ -133,7 +137,7 @@ int ViEAutoTestMain::RunSpecialTestCase(int choice) {
|
|||||||
case 7: errors = vieAutoTest.ViELoopbackCall(); break;
|
case 7: errors = vieAutoTest.ViELoopbackCall(); break;
|
||||||
case 8: errors = vieAutoTest.ViECustomCall(); break;
|
case 8: errors = vieAutoTest.ViECustomCall(); break;
|
||||||
case 9: errors = vieAutoTest.ViESimulcastCall(); break;
|
case 9: errors = vieAutoTest.ViESimulcastCall(); break;
|
||||||
case 10: errors = vieAutoTest.ViERecordCall(); break;
|
case 10: errors = vieAutoTest.ViERecordCall(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
windowCreator.TerminateWindows();
|
windowCreator.TerminateWindows();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user