| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/spellchecker/spellcheck_platform.h" | 5 #include "chrome/browser/spellchecker/spellcheck_platform.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 content::RunMessageLoop(); | 25 content::RunMessageLoop(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 std::vector<SpellCheckResult> results_; | 28 std::vector<SpellCheckResult> results_; |
| 29 spellcheck_platform::TextCheckCompleteCallback callback_; | 29 spellcheck_platform::TextCheckCompleteCallback callback_; |
| 30 bool callback_finished_; | 30 bool callback_finished_; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 void QuitMessageLoop() { | 33 void QuitMessageLoop() { |
| 34 CHECK(base::MessageLoop::current() == &message_loop_); | 34 CHECK(base::MessageLoop::current() == &message_loop_); |
| 35 base::MessageLoop::current()->Quit(); | 35 base::MessageLoop::current()->QuitWhenIdle(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void CompletionCallback(const std::vector<SpellCheckResult>& results) { | 38 void CompletionCallback(const std::vector<SpellCheckResult>& results) { |
| 39 results_ = results; | 39 results_ = results; |
| 40 callback_finished_ = true; | 40 callback_finished_ = true; |
| 41 message_loop_.PostTask(FROM_HERE, base::Bind( | 41 message_loop_.PostTask(FROM_HERE, base::Bind( |
| 42 &SpellcheckPlatformMacTest::QuitMessageLoop, | 42 &SpellcheckPlatformMacTest::QuitMessageLoop, |
| 43 base::Unretained(this))); | 43 base::Unretained(this))); |
| 44 } | 44 } |
| 45 | 45 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // RequestTextCheck results. | 383 // RequestTextCheck results. |
| 384 TEST_F(SpellcheckPlatformMacTest, SpellCheckIgnoresOrthography) { | 384 TEST_F(SpellcheckPlatformMacTest, SpellCheckIgnoresOrthography) { |
| 385 base::string16 test_string(base::ASCIIToUTF16("Icland is awesome.")); | 385 base::string16 test_string(base::ASCIIToUTF16("Icland is awesome.")); |
| 386 spellcheck_platform::RequestTextCheck(0, test_string, callback_); | 386 spellcheck_platform::RequestTextCheck(0, test_string, callback_); |
| 387 WaitForCallback(); | 387 WaitForCallback(); |
| 388 EXPECT_TRUE(callback_finished_); | 388 EXPECT_TRUE(callback_finished_); |
| 389 EXPECT_EQ(1U, results_.size()); | 389 EXPECT_EQ(1U, results_.size()); |
| 390 } | 390 } |
| 391 | 391 |
| 392 } // namespace | 392 } // namespace |
| OLD | NEW |