| 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 "ppapi/tests/test_view.h" | 5 #include "ppapi/tests/test_view.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "ppapi/c/pp_time.h" | 9 #include "ppapi/c/pp_time.h" |
| 10 #include "ppapi/c/dev/ppb_testing_dev.h" | 10 #include "ppapi/c/dev/ppb_testing_dev.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 ASSERT_FALSE(page_visibility_log_[0]); | 87 ASSERT_FALSE(page_visibility_log_[0]); |
| 88 PASS(); | 88 PASS(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 std::string TestView::TestPageHideShow() { | 91 std::string TestView::TestPageHideShow() { |
| 92 // Initial state should be visible. | 92 // Initial state should be visible. |
| 93 ASSERT_FALSE(page_visibility_log_.empty()); | 93 ASSERT_FALSE(page_visibility_log_.empty()); |
| 94 ASSERT_TRUE(page_visibility_log_[0]); | 94 ASSERT_TRUE(page_visibility_log_[0]); |
| 95 | 95 |
| 96 // Now that we're alive, set a cookie so the UI test knows it can change our | 96 // Now that we're alive, tell the test knows it can change our visibility. |
| 97 // visibility. | 97 instance_->ReportProgress("TestPageHideShow:Created"); |
| 98 instance_->SetCookie("TestPageHideShow:Created", "TRUE"); | |
| 99 | 98 |
| 100 // Wait until we get a hide event, being careful to handle spurious | 99 // Wait until we get a hide event, being careful to handle spurious |
| 101 // notifications of ViewChanged. | 100 // notifications of ViewChanged. |
| 102 PP_Time begin_time = pp::Module::Get()->core()->GetTime(); | 101 PP_Time begin_time = pp::Module::Get()->core()->GetTime(); |
| 103 while (WaitUntilViewChanged() && | 102 while (WaitUntilViewChanged() && |
| 104 page_visibility_log_[page_visibility_log_.size() - 1] && | 103 page_visibility_log_[page_visibility_log_.size() - 1] && |
| 105 pp::Module::Get()->core()->GetTime() - begin_time < | 104 pp::Module::Get()->core()->GetTime() - begin_time < |
| 106 kViewChangeTimeoutSec) { | 105 kViewChangeTimeoutSec) { |
| 107 } | 106 } |
| 108 if (page_visibility_log_[page_visibility_log_.size() - 1]) { | 107 if (page_visibility_log_[page_visibility_log_.size() - 1]) { |
| 109 // Didn't get a view changed event that changed visibility (though there | 108 // Didn't get a view changed event that changed visibility (though there |
| 110 // may have been some that didn't change visibility). | 109 // may have been some that didn't change visibility). |
| 111 // Add more error message since this test has some extra requirements. | 110 // Add more error message since this test has some extra requirements. |
| 112 return "Didn't receive a hide event in timeout. NOTE: " | 111 return "Didn't receive a hide event in timeout. NOTE: " |
| 113 "This test requires tab visibility to change and won't pass if you " | 112 "This test requires tab visibility to change and won't pass if you " |
| 114 "just run it in a browser. Normally the UI test should handle " | 113 "just run it in a browser. Normally the UI test should handle " |
| 115 "this. You can also run manually by waiting 2 secs, creating a new " | 114 "this. You can also run manually by waiting 2 secs, creating a new " |
| 116 "tab, waiting 2 more secs, and closing the new tab."; | 115 "tab, waiting 2 more secs, and closing the new tab."; |
| 117 } | 116 } |
| 118 | 117 |
| 119 // Set a cookie so the UI test knows it can show us again. | 118 // Tell the test so it can show us again. |
| 120 instance_->SetCookie("TestPageHideShow:Hidden", "TRUE"); | 119 instance_->ReportProgress("TestPageHideShow:Hidden"); |
| 121 | 120 |
| 122 // Wait until we get a show event. | 121 // Wait until we get a show event. |
| 123 begin_time = pp::Module::Get()->core()->GetTime(); | 122 begin_time = pp::Module::Get()->core()->GetTime(); |
| 124 while (WaitUntilViewChanged() && | 123 while (WaitUntilViewChanged() && |
| 125 !page_visibility_log_[page_visibility_log_.size() - 1] && | 124 !page_visibility_log_[page_visibility_log_.size() - 1] && |
| 126 pp::Module::Get()->core()->GetTime() - begin_time < | 125 pp::Module::Get()->core()->GetTime() - begin_time < |
| 127 kViewChangeTimeoutSec) { | 126 kViewChangeTimeoutSec) { |
| 128 } | 127 } |
| 129 ASSERT_TRUE(page_visibility_log_[page_visibility_log_.size() - 1]); | 128 ASSERT_TRUE(page_visibility_log_[page_visibility_log_.size() - 1]); |
| 130 | 129 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 desired_clip.set_height(desired_clip.height() - desired_clip.y()); | 187 desired_clip.set_height(desired_clip.height() - desired_clip.y()); |
| 189 | 188 |
| 190 PP_Time begin_time = pp::Module::Get()->core()->GetTime(); | 189 PP_Time begin_time = pp::Module::Get()->core()->GetTime(); |
| 191 while (WaitUntilViewChanged() && last_view_.GetClipRect() != desired_clip && | 190 while (WaitUntilViewChanged() && last_view_.GetClipRect() != desired_clip && |
| 192 pp::Module::Get()->core()->GetTime() - begin_time < | 191 pp::Module::Get()->core()->GetTime() - begin_time < |
| 193 kViewChangeTimeoutSec) { | 192 kViewChangeTimeoutSec) { |
| 194 } | 193 } |
| 195 ASSERT_TRUE(last_view_.GetClipRect() == desired_clip); | 194 ASSERT_TRUE(last_view_.GetClipRect() == desired_clip); |
| 196 PASS(); | 195 PASS(); |
| 197 } | 196 } |
| OLD | NEW |