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

Unified Diff: ppapi/tests/test_flash_clipboard.cc

Issue 8515014: Fix flaky PPAPITest.FlashClipboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Do the same thing for IsFormatAvailable. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/tests/test_core.cc ('k') | ppapi/tests/test_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_flash_clipboard.cc
diff --git a/ppapi/tests/test_flash_clipboard.cc b/ppapi/tests/test_flash_clipboard.cc
index 600dad3d433644a49386183884c8b40c1d1e2357..885260a43fa69ac0d9b49d182f129d2ae2d26117 100644
--- a/ppapi/tests/test_flash_clipboard.cc
+++ b/ppapi/tests/test_flash_clipboard.cc
@@ -33,17 +33,38 @@ std::string TestFlashClipboard::TestReadWrite() {
PP_FLASH_CLIPBOARD_TYPE_STANDARD,
input_var.pp_var());
- ASSERT_TRUE(clipboard_interface_->IsFormatAvailable(
- instance_->pp_instance(),
- PP_FLASH_CLIPBOARD_TYPE_STANDARD,
- PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT));
+ // WritePlainText() causes an async request sent to the browser process.
+ // As a result, the string written may not be reflected by IsFormatAvailable()
+ // or ReadPlainText() immediately. We need to wait and retry.
Paweł Hajdan Jr. 2011/11/14 12:32:48 I'm not sure how well this will work. If you reall
dmichael (off chromium) 2011/11/14 15:48:15 Oops, he is right. I wasn't looking carefully enou
+ const int kIntervalMs = 250;
+ const int kMaxIntervals = kActionTimeoutMs / kIntervalMs;
- pp::Var result_var(pp::Var::PassRef(),
- clipboard_interface_->ReadPlainText(instance_->pp_instance(),
- PP_FLASH_CLIPBOARD_TYPE_STANDARD));
- ASSERT_TRUE(result_var.is_string());
+ PP_Bool is_available = PP_FALSE;
+ for (int i = 0; i < kMaxIntervals; ++i) {
+ is_available = clipboard_interface_->IsFormatAvailable(
+ instance_->pp_instance(),
+ PP_FLASH_CLIPBOARD_TYPE_STANDARD,
+ PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT);
+ if (is_available)
+ break;
+
+ PlatformSleep(kIntervalMs);
+ }
+ ASSERT_TRUE(is_available);
+
+ std::string result_str;
+ for (int i = 0; i < kMaxIntervals; ++i) {
+ pp::Var result_var(pp::Var::PassRef(),
+ clipboard_interface_->ReadPlainText(instance_->pp_instance(),
+ PP_FLASH_CLIPBOARD_TYPE_STANDARD));
+ ASSERT_TRUE(result_var.is_string());
+ result_str = result_var.AsString();
+ if (result_str == input_str)
+ break;
+
+ PlatformSleep(kIntervalMs);
+ }
- std::string result_str = result_var.AsString();
ASSERT_TRUE(result_str == input_str);
PASS();
}
« no previous file with comments | « ppapi/tests/test_core.cc ('k') | ppapi/tests/test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698