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

Side by Side Diff: chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc

Issue 1827083004: UI: Rename MediaState to AlertState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-tab-indicator
Patch Set: Keep gypi ordered Created 4 years, 8 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/app/generated_resources.grd ('k') | chrome/browser/extensions/api/tabs/tabs_api.cc » ('j') | 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/location.h" 6 #include "base/location.h"
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 401
402 // http://crbug.com/177163 402 // http://crbug.com/177163
403 #if defined(OS_WIN) && !defined(NDEBUG) 403 #if defined(OS_WIN) && !defined(NDEBUG)
404 #define MAYBE_TabIndicator DISABLED_TabIndicator 404 #define MAYBE_TabIndicator DISABLED_TabIndicator
405 #else 405 #else
406 // Also flaky everywhere else: https://crbug.com/530657 406 // Also flaky everywhere else: https://crbug.com/530657
407 #define MAYBE_TabIndicator DISABLED_TabIndicator 407 #define MAYBE_TabIndicator DISABLED_TabIndicator
408 #endif 408 #endif
409 // Tests that the tab indicator (in the tab strip) is shown during tab capture. 409 // Tests that the tab indicator (in the tab strip) is shown during tab capture.
410 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_TabIndicator) { 410 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_TabIndicator) {
411 ASSERT_EQ(TAB_MEDIA_STATE_NONE, 411 ASSERT_EQ(TabAlertState::NONE,
412 chrome::GetTabMediaStateForContents( 412 chrome::GetTabAlertStateForContents(
413 browser()->tab_strip_model()->GetActiveWebContents())); 413 browser()->tab_strip_model()->GetActiveWebContents()));
414 414
415 // Run an extension test that just turns on tab capture, which should cause 415 // Run an extension test that just turns on tab capture, which should cause
416 // the indicator to turn on. 416 // the indicator to turn on.
417 AddExtensionToCommandLineWhitelist(); 417 AddExtensionToCommandLineWhitelist();
418 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "start_tab_capture.html")) 418 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "start_tab_capture.html"))
419 << message_; 419 << message_;
420 420
421 // A TabStripModelObserver that quits the MessageLoop whenever the UI's model 421 // A TabStripModelObserver that quits the MessageLoop whenever the UI's model
422 // is sent an event that changes the indicator status. 422 // is sent an event that changes the indicator status.
423 class IndicatorChangeObserver : public TabStripModelObserver { 423 class IndicatorChangeObserver : public TabStripModelObserver {
424 public: 424 public:
425 explicit IndicatorChangeObserver(Browser* browser) 425 explicit IndicatorChangeObserver(Browser* browser)
426 : last_media_state_(chrome::GetTabMediaStateForContents( 426 : last_alert_state_(chrome::GetTabAlertStateForContents(
427 browser->tab_strip_model()->GetActiveWebContents())) {} 427 browser->tab_strip_model()->GetActiveWebContents())) {}
428 428
429 TabMediaState last_media_state() const { return last_media_state_; } 429 TabAlertState last_alert_state() const { return last_alert_state_; }
430 430
431 void TabChangedAt(content::WebContents* contents, 431 void TabChangedAt(content::WebContents* contents,
432 int index, 432 int index,
433 TabChangeType change_type) override { 433 TabChangeType change_type) override {
434 const TabMediaState media_state = 434 const TabAlertState alert_state =
435 chrome::GetTabMediaStateForContents(contents); 435 chrome::GetTabAlertStateForContents(contents);
436 const bool has_changed = media_state != last_media_state_; 436 const bool has_changed = alert_state != last_alert_state_;
437 last_media_state_ = media_state; 437 last_alert_state_ = alert_state;
438 if (has_changed) { 438 if (has_changed) {
439 base::ThreadTaskRunnerHandle::Get()->PostTask( 439 base::ThreadTaskRunnerHandle::Get()->PostTask(
440 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 440 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
441 } 441 }
442 } 442 }
443 443
444 private: 444 private:
445 TabMediaState last_media_state_; 445 TabAlertState last_alert_state_;
446 }; 446 };
447 447
448 // Run the browser until the indicator turns on. 448 // Run the browser until the indicator turns on.
449 IndicatorChangeObserver observer(browser()); 449 IndicatorChangeObserver observer(browser());
450 browser()->tab_strip_model()->AddObserver(&observer); 450 browser()->tab_strip_model()->AddObserver(&observer);
451 const base::TimeTicks start_time = base::TimeTicks::Now(); 451 const base::TimeTicks start_time = base::TimeTicks::Now();
452 while (observer.last_media_state() != TAB_MEDIA_STATE_CAPTURING) { 452 while (observer.last_alert_state() != TabAlertState::TAB_CAPTURING) {
453 if (base::TimeTicks::Now() - start_time > 453 if (base::TimeTicks::Now() - start_time >
454 base::TimeDelta::FromSeconds(10)) { 454 base::TimeDelta::FromSeconds(10)) {
455 EXPECT_EQ(TAB_MEDIA_STATE_CAPTURING, observer.last_media_state()); 455 EXPECT_EQ(TabAlertState::TAB_CAPTURING, observer.last_alert_state());
456 browser()->tab_strip_model()->RemoveObserver(&observer); 456 browser()->tab_strip_model()->RemoveObserver(&observer);
457 return; 457 return;
458 } 458 }
459 content::RunMessageLoop(); 459 content::RunMessageLoop();
460 } 460 }
461 browser()->tab_strip_model()->RemoveObserver(&observer); 461 browser()->tab_strip_model()->RemoveObserver(&observer);
462 } 462 }
463 463
464 } // namespace 464 } // namespace
465 465
466 } // namespace extensions 466 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/api/tabs/tabs_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698