Commit 1060e2a0 authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Revert "Include line numbers in SpeechMonitor async api"

This reverts commit 59211f2c.

Reason for revert: Persistent failures on linux-chromeos-chrome waterfall bot

starting https://ci.chromium.org/p/chrome/builders/ci/linux-chromeos-chrome/4305

errors like

../../chrome/browser/chromeos/accessibility/speech_monitor.h:64:54: error: predefined identifier is only valid inside function [-Werror,-Wpredefined-identifier-outside-function]
const base::Location& location = FROM_HERE);

Original change's description:
> Include line numbers in SpeechMonitor async api
> 
> Unfortunately, to resolve base::Location for each api call, we cannot support chaining.
> 
> However, shortening the variable name for
> |speech_monitor_|
> to
> |sm_|
> and not having to indent, we actually save some indent space.
> 
> Also, this change now includes all pending utterances (for understanding the state when the test is waiting).
> 
> Sample output:
> [158567:158567:0325/082550.588956:ERROR:speech_monitor.cc(276)] Still waiting for expectation(s).
> Unsatisfied expectations...
> ExpectSpeech("Fail!Rate 19 percent") RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:931
> Call() RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:933
> ExpectSpeech("Pitch 50 percent") RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:934
> Call() RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:936
> ExpectSpeech("Reset text to speech settings to default values") RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:938
> Call() RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:941
> ExpectSpeech("Rate 19 percent") RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:942
> Call() RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:943
> ExpectSpeech("Pitch 50 percent") RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:944
> 
> pending speech utterances...
> Volume 100 percent
> Rate 19 percent
> 
> Satisfied expectations...
> Call() RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:926
> ExpectSpeech("Reset text to speech settings to default values") RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:928
> Call() RunTestOnMainThread@../../chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc:930
> 
> Change-Id: If1bdbfb517014e681cb233800eab3f62f608188f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2120741
> Reviewed-by: Akihiro Ota <akihiroota@chromium.org>
> Commit-Queue: David Tseng <dtseng@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#753353}

TBR=dmazzoni@chromium.org,dtseng@chromium.org,akihiroota@chromium.org

Change-Id: Ib3acf61914b3dd81ce2d777961d16de060ae9192
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2121598
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753518}
parent 18e2d4a0
...@@ -161,8 +161,7 @@ double SpeechMonitor::GetDelayForLastUtteranceMS() { ...@@ -161,8 +161,7 @@ double SpeechMonitor::GetDelayForLastUtteranceMS() {
return delay_for_last_utterance_ms_; return delay_for_last_utterance_ms_;
} }
void SpeechMonitor::ExpectSpeech(const std::string& text, SpeechMonitor& SpeechMonitor::ExpectSpeech(const std::string& text) {
const base::Location& location) {
CHECK(!replay_loop_runner_.get()); CHECK(!replay_loop_runner_.get());
replay_queue_.push_back({[this, text]() { replay_queue_.push_back({[this, text]() {
for (auto it = utterance_queue_.begin(); for (auto it = utterance_queue_.begin();
...@@ -177,12 +176,11 @@ void SpeechMonitor::ExpectSpeech(const std::string& text, ...@@ -177,12 +176,11 @@ void SpeechMonitor::ExpectSpeech(const std::string& text,
} }
return false; return false;
}, },
"ExpectSpeech(\"" + text + "\") " + "ExpectSpeech(\"" + text + "\")"});
location.ToString()}); return *this;
} }
void SpeechMonitor::ExpectSpeechPattern(const std::string& pattern, SpeechMonitor& SpeechMonitor::ExpectSpeechPattern(const std::string& pattern) {
const base::Location& location) {
CHECK(!replay_loop_runner_.get()); CHECK(!replay_loop_runner_.get());
replay_queue_.push_back({[this, pattern]() { replay_queue_.push_back({[this, pattern]() {
for (auto it = utterance_queue_.begin(); for (auto it = utterance_queue_.begin();
...@@ -197,31 +195,30 @@ void SpeechMonitor::ExpectSpeechPattern(const std::string& pattern, ...@@ -197,31 +195,30 @@ void SpeechMonitor::ExpectSpeechPattern(const std::string& pattern,
} }
return false; return false;
}, },
"ExpectSpeechPattern(\"" + pattern + "\") " + "ExpectSpeechPattern(\"" + pattern + "\")"});
location.ToString()}); return *this;
} }
void SpeechMonitor::ExpectNextSpeechIsNot(const std::string& text, SpeechMonitor& SpeechMonitor::ExpectNextSpeechIsNot(const std::string& text) {
const base::Location& location) {
CHECK(!replay_loop_runner_.get()); CHECK(!replay_loop_runner_.get());
replay_queue_.push_back( replay_queue_.push_back({[this, text]() {
{[this, text]() { if (utterance_queue_.empty())
if (utterance_queue_.empty()) return false;
return false;
return text != utterance_queue_.front().text;
return text != utterance_queue_.front().text; },
}, "ExpectNextSpeechIsNot(\"" + text + "\")"});
"ExpectNextSpeechIsNot(\"" + text + "\") " + location.ToString()}); return *this;
} }
void SpeechMonitor::Call(std::function<void()> func, SpeechMonitor& SpeechMonitor::Call(std::function<void()> func) {
const base::Location& location) {
CHECK(!replay_loop_runner_.get()); CHECK(!replay_loop_runner_.get());
replay_queue_.push_back({[func]() { replay_queue_.push_back({[func]() {
func(); func();
return true; return true;
}, },
"Call() " + location.ToString()}); "Call()"});
return *this;
} }
void SpeechMonitor::Replay() { void SpeechMonitor::Replay() {
...@@ -269,15 +266,9 @@ void SpeechMonitor::MaybePrintExpectations() { ...@@ -269,15 +266,9 @@ void SpeechMonitor::MaybePrintExpectations() {
for (const auto& pair : replay_queue_) for (const auto& pair : replay_queue_)
replay_queue_descriptions.push_back(pair.second); replay_queue_descriptions.push_back(pair.second);
std::vector<std::string> utterance_queue_descriptions;
for (const auto& item : utterance_queue_)
utterance_queue_descriptions.push_back("\"" + item.text + "\"");
LOG(ERROR) << "Still waiting for expectation(s).\n" LOG(ERROR) << "Still waiting for expectation(s).\n"
<< "Unsatisfied expectations...\n" << "Unsatisfied expectations...\n"
<< base::JoinString(replay_queue_descriptions, "\n") << "\n\n" << base::JoinString(replay_queue_descriptions, "\n") << "\n\n\n"
<< "pending speech utterances...\n"
<< base::JoinString(utterance_queue_descriptions, "\n") << "\n\n"
<< "Satisfied expectations...\n" << "Satisfied expectations...\n"
<< base::JoinString(replayed_queue_, "\n"); << base::JoinString(replayed_queue_, "\n");
} }
......
...@@ -55,21 +55,17 @@ class SpeechMonitor : public content::TtsPlatform { ...@@ -55,21 +55,17 @@ class SpeechMonitor : public content::TtsPlatform {
// Non-blocking api. // Non-blocking api.
// Use these apis if you want to write an async test e.g. // Use these apis if you want to write an async test e.g.
// sm_.ExpectSpeech("foo"); // speech_monitor_.ExpectSpeech("foo")
// sm_.Call([this]() { DoSomething(); }) // .Call([this]() { DoSomething(); })
// sm_.Replay(); // .Replay();
// Adds an expectation of spoken text. // Adds an expectation of spoken text.
void ExpectSpeech(const std::string& text, SpeechMonitor& ExpectSpeech(const std::string& text);
const base::Location& location = FROM_HERE); SpeechMonitor& ExpectSpeechPattern(const std::string& pattern);
void ExpectSpeechPattern(const std::string& pattern, SpeechMonitor& ExpectNextSpeechIsNot(const std::string& text);
const base::Location& location = FROM_HERE);
void ExpectNextSpeechIsNot(const std::string& text,
const base::Location& location = FROM_HERE);
// Adds a call to be included in replay. // Adds a call to be included in replay.
void Call(std::function<void()> func, SpeechMonitor& Call(std::function<void()> func);
const base::Location& location = FROM_HERE);
// Replays all expectations. // Replays all expectations.
void Replay(); void Replay();
......
...@@ -49,7 +49,7 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest { ...@@ -49,7 +49,7 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
void PressRepeatedlyUntilUtterance(ui::KeyboardCode key, void PressRepeatedlyUntilUtterance(ui::KeyboardCode key,
const std::string& expected_utterance); const std::string& expected_utterance);
SpeechMonitor sm_; SpeechMonitor speech_monitor_;
private: private:
StubBrailleController braille_controller_; StubBrailleController braille_controller_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment