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

Side by Side Diff: chrome/test/base/ui_test_utils.cc

Issue 2441543004: Refactor BrowserActivationWaiter as test support and move PopupBlockerBrowserTest to interactive_ui… (Closed)
Patch Set: Created 4 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 scoped_refptr<content::MessageLoopRunner> runner = 533 scoped_refptr<content::MessageLoopRunner> runner =
534 new content::MessageLoopRunner; 534 new content::MessageLoopRunner;
535 WaitHistoryLoadedObserver observer(runner.get()); 535 WaitHistoryLoadedObserver observer(runner.get());
536 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> 536 ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
537 scoped_observer(&observer); 537 scoped_observer(&observer);
538 scoped_observer.Add(history_service); 538 scoped_observer.Add(history_service);
539 runner->Run(); 539 runner->Run();
540 } 540 }
541 } 541 }
542 542
543 BrowserActivationWaiter::BrowserActivationWaiter(Browser* browser)
544 : browser_(browser), observed_(false) {
545 if (chrome::FindLastActive() == browser_) {
546 observed_ = true;
547 return;
548 }
549 BrowserList::AddObserver(this);
550 }
551
552 BrowserActivationWaiter::~BrowserActivationWaiter() {}
553
554 void BrowserActivationWaiter::WaitForActivation() {
555 if (observed_)
556 return;
557 message_loop_runner_ = new content::MessageLoopRunner;
558 message_loop_runner_->Run();
559 }
560
561 void BrowserActivationWaiter::OnBrowserSetLastActive(Browser* browser) {
562 if (browser != browser_)
563 return;
564
565 observed_ = true;
566 BrowserList::RemoveObserver(this);
567 if (message_loop_runner_.get() && message_loop_runner_->loop_running())
568 message_loop_runner_->Quit();
569 }
570
543 } // namespace ui_test_utils 571 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698