| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/media/desktop_media_list_ash.h" | 5 #include "chrome/browser/media/desktop_media_list_ash.h" |
| 6 | 6 |
| 7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
| 8 #include "base/location.h" |
| 8 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" |
| 9 #include "chrome/browser/media/desktop_media_list_observer.h" | 12 #include "chrome/browser/media/desktop_media_list_observer.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 13 | 16 |
| 14 int kThumbnailSize = 100; | 17 int kThumbnailSize = 100; |
| 15 | 18 |
| 16 using testing::AtLeast; | 19 using testing::AtLeast; |
| 17 using testing::DoDefault; | 20 using testing::DoDefault; |
| 18 | 21 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 list_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(1)); | 41 list_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(1)); |
| 39 } | 42 } |
| 40 | 43 |
| 41 protected: | 44 protected: |
| 42 MockDesktopMediaListObserver observer_; | 45 MockDesktopMediaListObserver observer_; |
| 43 scoped_ptr<DesktopMediaListAsh> list_; | 46 scoped_ptr<DesktopMediaListAsh> list_; |
| 44 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListAshTest); | 47 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListAshTest); |
| 45 }; | 48 }; |
| 46 | 49 |
| 47 ACTION(QuitMessageLoop) { | 50 ACTION(QuitMessageLoop) { |
| 48 base::MessageLoop::current()->PostTask( | 51 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 49 FROM_HERE, base::MessageLoop::QuitClosure()); | 52 FROM_HERE, base::MessageLoop::QuitClosure()); |
| 50 } | 53 } |
| 51 | 54 |
| 52 TEST_F(DesktopMediaListAshTest, Screen) { | 55 TEST_F(DesktopMediaListAshTest, Screen) { |
| 53 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS); | 56 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS); |
| 54 | 57 |
| 55 EXPECT_CALL(observer_, OnSourceAdded(0)); | 58 EXPECT_CALL(observer_, OnSourceAdded(0)); |
| 56 EXPECT_CALL(observer_, OnSourceThumbnailChanged(0)) | 59 EXPECT_CALL(observer_, OnSourceThumbnailChanged(0)) |
| 57 .WillOnce(QuitMessageLoop()) | 60 .WillOnce(QuitMessageLoop()) |
| 58 .WillRepeatedly(DoDefault()); | 61 .WillRepeatedly(DoDefault()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 .WillOnce(QuitMessageLoop()) | 108 .WillOnce(QuitMessageLoop()) |
| 106 .WillRepeatedly(DoDefault()); | 109 .WillRepeatedly(DoDefault()); |
| 107 EXPECT_CALL(observer_, OnSourceRemoved(0)) | 110 EXPECT_CALL(observer_, OnSourceRemoved(0)) |
| 108 .WillOnce(QuitMessageLoop()); | 111 .WillOnce(QuitMessageLoop()); |
| 109 | 112 |
| 110 list_->StartUpdating(&observer_); | 113 list_->StartUpdating(&observer_); |
| 111 base::MessageLoop::current()->Run(); | 114 base::MessageLoop::current()->Run(); |
| 112 window.reset(); | 115 window.reset(); |
| 113 base::MessageLoop::current()->Run(); | 116 base::MessageLoop::current()->Run(); |
| 114 } | 117 } |
| OLD | NEW |