Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: media/cast/test/utility/input_builder.cc

Issue 184813009: Cast Streaming API end-to-end browser_test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix LoggingImplTest + REBASE Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/test/utility/input_builder.h" 5 #include "media/cast/test/utility/input_builder.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <cstdio> 8 #include <cstdio>
9 9
10 #include "base/command_line.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 13
13 namespace media { 14 namespace media {
14 namespace cast { 15 namespace cast {
15 namespace test { 16 namespace test {
16 17
18 static const char kEnablePromptsSwitch[] = "enable-prompts";
19
17 InputBuilder::InputBuilder(const std::string& title, 20 InputBuilder::InputBuilder(const std::string& title,
18 const std::string& default_value, 21 const std::string& default_value,
19 int low_range, 22 int low_range,
20 int high_range) 23 int high_range)
21 : title_(title), 24 : title_(title),
22 default_value_(default_value), 25 default_value_(default_value),
23 low_range_(low_range), 26 low_range_(low_range),
24 high_range_(high_range) {} 27 high_range_(high_range) {}
25 28
26 InputBuilder::~InputBuilder() {} 29 InputBuilder::~InputBuilder() {}
27 30
28 std::string InputBuilder::GetStringInput() const { 31 std::string InputBuilder::GetStringInput() const {
32 if (!CommandLine::ForCurrentProcess()->HasSwitch(kEnablePromptsSwitch))
33 return default_value_;
34
29 printf("\n%s\n", title_.c_str()); 35 printf("\n%s\n", title_.c_str());
30 if (!default_value_.empty()) 36 if (!default_value_.empty())
31 printf("Hit enter for default (%s):\n", default_value_.c_str()); 37 printf("Hit enter for default (%s):\n", default_value_.c_str());
32 38
33 printf("# "); 39 printf("# ");
34 fflush(stdout); 40 fflush(stdout);
35 char raw_input[128]; 41 char raw_input[128];
36 if (!fgets(raw_input, 128, stdin)) { 42 if (!fgets(raw_input, 128, stdin)) {
37 NOTREACHED(); 43 NOTREACHED();
38 return std::string(); 44 return std::string();
(...skipping 24 matching lines...) Expand all
63 return true; 69 return true;
64 int value; 70 int value;
65 if (!base::StringToInt(input, &value)) 71 if (!base::StringToInt(input, &value))
66 return false; 72 return false;
67 return value >= low_range_ && value <= high_range_; 73 return value >= low_range_ && value <= high_range_;
68 } 74 }
69 75
70 } // namespace test 76 } // namespace test
71 } // namespace cast 77 } // namespace cast
72 } // namespace media 78 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/test/utility/in_process_receiver.cc ('k') | media/cast/test/utility/standalone_cast_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698