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() {
return delay_for_last_utterance_ms_;
}
void SpeechMonitor::ExpectSpeech(const std::string& text,
const base::Location& location) {
SpeechMonitor& SpeechMonitor::ExpectSpeech(const std::string& text) {
CHECK(!replay_loop_runner_.get());
replay_queue_.push_back({[this, text]() {
for (auto it = utterance_queue_.begin();
......@@ -177,12 +176,11 @@ void SpeechMonitor::ExpectSpeech(const std::string& text,
}
return false;
},
"ExpectSpeech(\"" + text + "\") " +
location.ToString()});
"ExpectSpeech(\"" + text + "\")"});
return *this;
}
void SpeechMonitor::ExpectSpeechPattern(const std::string& pattern,
const base::Location& location) {
SpeechMonitor& SpeechMonitor::ExpectSpeechPattern(const std::string& pattern) {
CHECK(!replay_loop_runner_.get());
replay_queue_.push_back({[this, pattern]() {
for (auto it = utterance_queue_.begin();
......@@ -197,31 +195,30 @@ void SpeechMonitor::ExpectSpeechPattern(const std::string& pattern,
}
return false;
},
"ExpectSpeechPattern(\"" + pattern + "\") " +
location.ToString()});
"ExpectSpeechPattern(\"" + pattern + "\")"});
return *this;
}
void SpeechMonitor::ExpectNextSpeechIsNot(const std::string& text,
const base::Location& location) {
SpeechMonitor& SpeechMonitor::ExpectNextSpeechIsNot(const std::string& text) {
CHECK(!replay_loop_runner_.get());
replay_queue_.push_back(
{[this, text]() {
if (utterance_queue_.empty())
return false;
return text != utterance_queue_.front().text;
},
"ExpectNextSpeechIsNot(\"" + text + "\") " + location.ToString()});
replay_queue_.push_back({[this, text]() {
if (utterance_queue_.empty())
return false;
return text != utterance_queue_.front().text;
},
"ExpectNextSpeechIsNot(\"" + text + "\")"});
return *this;
}
void SpeechMonitor::Call(std::function<void()> func,
const base::Location& location) {
SpeechMonitor& SpeechMonitor::Call(std::function<void()> func) {
CHECK(!replay_loop_runner_.get());
replay_queue_.push_back({[func]() {
func();
return true;
},
"Call() " + location.ToString()});
"Call()"});
return *this;
}
void SpeechMonitor::Replay() {
......@@ -269,15 +266,9 @@ void SpeechMonitor::MaybePrintExpectations() {
for (const auto& pair : replay_queue_)
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"
<< "Unsatisfied expectations...\n"
<< base::JoinString(replay_queue_descriptions, "\n") << "\n\n"
<< "pending speech utterances...\n"
<< base::JoinString(utterance_queue_descriptions, "\n") << "\n\n"
<< base::JoinString(replay_queue_descriptions, "\n") << "\n\n\n"
<< "Satisfied expectations...\n"
<< base::JoinString(replayed_queue_, "\n");
}
......
......@@ -55,21 +55,17 @@ class SpeechMonitor : public content::TtsPlatform {
// Non-blocking api.
// Use these apis if you want to write an async test e.g.
// sm_.ExpectSpeech("foo");
// sm_.Call([this]() { DoSomething(); })
// sm_.Replay();
// speech_monitor_.ExpectSpeech("foo")
// .Call([this]() { DoSomething(); })
// .Replay();
// Adds an expectation of spoken text.
void ExpectSpeech(const std::string& text,
const base::Location& location = FROM_HERE);
void ExpectSpeechPattern(const std::string& pattern,
const base::Location& location = FROM_HERE);
void ExpectNextSpeechIsNot(const std::string& text,
const base::Location& location = FROM_HERE);
SpeechMonitor& ExpectSpeech(const std::string& text);
SpeechMonitor& ExpectSpeechPattern(const std::string& pattern);
SpeechMonitor& ExpectNextSpeechIsNot(const std::string& text);
// Adds a call to be included in replay.
void Call(std::function<void()> func,
const base::Location& location = FROM_HERE);
SpeechMonitor& Call(std::function<void()> func);
// Replays all expectations.
void Replay();
......
......@@ -49,7 +49,7 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
void PressRepeatedlyUntilUtterance(ui::KeyboardCode key,
const std::string& expected_utterance);
SpeechMonitor sm_;
SpeechMonitor speech_monitor_;
private:
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