Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/frame_host/interstitial_page_impl.h" | 5 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 "create_input_and_set_text('" + text + "')"); | 285 "create_input_and_set_text('" + text + "')"); |
| 286 } | 286 } |
| 287 | 287 |
| 288 bool SetSelectionChangeListener() { | 288 bool SetSelectionChangeListener() { |
| 289 return ExecuteScript(interstitial_->GetMainFrame(), | 289 return ExecuteScript(interstitial_->GetMainFrame(), |
| 290 "set_selection_change_listener()"); | 290 "set_selection_change_listener()"); |
| 291 } | 291 } |
| 292 | 292 |
| 293 std::string PerformCut() { | 293 std::string PerformCut() { |
| 294 clipboard_message_watcher_->InitWait(); | 294 clipboard_message_watcher_->InitWait(); |
| 295 title_update_watcher_->InitWait("TEXT_CHANGED"); | 295 title_update_watcher_->InitWait("TEXT_CHANGED"); |
|
Charlie Reis
2016/07/13 22:21:47
Is it still useful to keep the old title_update_wa
afakhry
2016/07/13 22:52:50
It's probably redundant. I also don't feel strongl
| |
| 296 const base::string16 expected_title = base::UTF8ToUTF16("TEXT_CHANGED"); | |
| 297 content::TitleWatcher title_watcher(shell()->web_contents(), | |
| 298 expected_title); | |
| 296 RenderFrameHostImpl* rfh = | 299 RenderFrameHostImpl* rfh = |
| 297 static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame()); | 300 static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame()); |
| 298 rfh->GetRenderWidgetHost()->delegate()->Cut(); | 301 rfh->GetRenderWidgetHost()->delegate()->Cut(); |
| 299 clipboard_message_watcher_->WaitForWriteCommit(); | 302 clipboard_message_watcher_->WaitForWriteCommit(); |
| 300 title_update_watcher_->Wait(); | 303 title_update_watcher_->Wait(); |
| 304 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | |
| 301 return clipboard_message_watcher_->last_text(); | 305 return clipboard_message_watcher_->last_text(); |
| 302 } | 306 } |
| 303 | 307 |
| 304 std::string PerformCopy() { | 308 std::string PerformCopy() { |
| 305 clipboard_message_watcher_->InitWait(); | 309 clipboard_message_watcher_->InitWait(); |
| 306 RenderFrameHostImpl* rfh = | 310 RenderFrameHostImpl* rfh = |
| 307 static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame()); | 311 static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame()); |
| 308 rfh->GetRenderWidgetHost()->delegate()->Copy(); | 312 rfh->GetRenderWidgetHost()->delegate()->Copy(); |
| 309 clipboard_message_watcher_->WaitForWriteCommit(); | 313 clipboard_message_watcher_->WaitForWriteCommit(); |
| 310 return clipboard_message_watcher_->last_text(); | 314 return clipboard_message_watcher_->last_text(); |
| 311 } | 315 } |
| 312 | 316 |
| 313 void PerformPaste() { | 317 void PerformPaste() { |
| 314 title_update_watcher_->InitWait("TEXT_CHANGED"); | 318 title_update_watcher_->InitWait("TEXT_CHANGED"); |
| 319 const base::string16 expected_title = base::UTF8ToUTF16("TEXT_CHANGED"); | |
| 320 content::TitleWatcher title_watcher(shell()->web_contents(), | |
| 321 expected_title); | |
| 315 RenderFrameHostImpl* rfh = | 322 RenderFrameHostImpl* rfh = |
| 316 static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame()); | 323 static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame()); |
| 317 rfh->GetRenderWidgetHost()->delegate()->Paste(); | 324 rfh->GetRenderWidgetHost()->delegate()->Paste(); |
| 318 title_update_watcher_->Wait(); | 325 title_update_watcher_->Wait(); |
| 326 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | |
| 319 } | 327 } |
| 320 | 328 |
| 321 void PerformSelectAll() { | 329 void PerformSelectAll() { |
| 322 title_update_watcher_->InitWait("SELECTION_CHANGED"); | 330 title_update_watcher_->InitWait("SELECTION_CHANGED"); |
| 331 const base::string16 expected_title = | |
| 332 base::UTF8ToUTF16("SELECTION_CHANGED"); | |
| 333 content::TitleWatcher title_watcher(shell()->web_contents(), | |
| 334 expected_title); | |
| 323 RenderFrameHostImpl* rfh = | 335 RenderFrameHostImpl* rfh = |
| 324 static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame()); | 336 static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame()); |
| 325 rfh->GetRenderWidgetHost()->delegate()->SelectAll(); | 337 rfh->GetRenderWidgetHost()->delegate()->SelectAll(); |
| 326 title_update_watcher_->Wait(); | 338 title_update_watcher_->Wait(); |
| 339 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | |
| 327 } | 340 } |
| 328 | 341 |
| 329 private: | 342 private: |
| 330 void RunTaskOnIOThreadAndWait(const base::Closure& task) { | 343 void RunTaskOnIOThreadAndWait(const base::Closure& task) { |
| 331 base::WaitableEvent completion( | 344 base::WaitableEvent completion( |
| 332 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 345 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 333 base::WaitableEvent::InitialState::NOT_SIGNALED); | 346 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 334 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 347 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 335 base::Bind(&InterstitialPageImplTest::RunTask, this, | 348 base::Bind(&InterstitialPageImplTest::RunTask, this, |
| 336 task, &completion)); | 349 task, &completion)); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 | 423 |
| 411 PerformSelectAll(); | 424 PerformSelectAll(); |
| 412 | 425 |
| 413 ASSERT_TRUE(GetSelection(&input_text)); | 426 ASSERT_TRUE(GetSelection(&input_text)); |
| 414 EXPECT_EQ("original body text", input_text); | 427 EXPECT_EQ("original body text", input_text); |
| 415 | 428 |
| 416 TearDownInterstitialPage(); | 429 TearDownInterstitialPage(); |
| 417 } | 430 } |
| 418 | 431 |
| 419 } // namespace content | 432 } // namespace content |
| OLD | NEW |