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

Side by Side Diff: chrome/browser/media/webrtc/desktop_media_list_ash_unittest.cc

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: Added comments to explain the reset() Created 4 years 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 | « ash/test/ash_test_helper.cc ('k') | components/exo/BUILD.gn » ('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 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/webrtc/desktop_media_list_ash.h" 5 #include "chrome/browser/media/webrtc/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/location.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 27 matching lines...) Expand all
38 DesktopMediaListAshTest() {} 38 DesktopMediaListAshTest() {}
39 ~DesktopMediaListAshTest() override {} 39 ~DesktopMediaListAshTest() override {}
40 40
41 void CreateList(int source_types) { 41 void CreateList(int source_types) {
42 list_.reset(new DesktopMediaListAsh(source_types)); 42 list_.reset(new DesktopMediaListAsh(source_types));
43 list_->SetThumbnailSize(gfx::Size(kThumbnailSize, kThumbnailSize)); 43 list_->SetThumbnailSize(gfx::Size(kThumbnailSize, kThumbnailSize));
44 44
45 // Set update period to reduce the time it takes to run tests. 45 // Set update period to reduce the time it takes to run tests.
46 list_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(1)); 46 list_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(1));
47 } 47 }
48 48
sadrul 2016/12/10 05:04:43 I think you need to override TearDown() here: v
Alex Z. 2016/12/10 14:03:39 Yes, there needs to be a RenAllPendingInMessageLoo
49 protected: 49 protected:
50 MockDesktopMediaListObserver observer_; 50 MockDesktopMediaListObserver observer_;
51 std::unique_ptr<DesktopMediaListAsh> list_; 51 std::unique_ptr<DesktopMediaListAsh> list_;
52 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListAshTest); 52 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListAshTest);
53 }; 53 };
54 54
55 ACTION(QuitMessageLoop) { 55 ACTION(QuitMessageLoop) {
56 base::ThreadTaskRunnerHandle::Get()->PostTask( 56 base::ThreadTaskRunnerHandle::Get()->PostTask(
57 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 57 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
58 } 58 }
59 59
60 TEST_F(DesktopMediaListAshTest, Screen) { 60 TEST_F(DesktopMediaListAshTest, Screen) {
61 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS); 61 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS);
62 62
63 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); 63 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0));
64 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) 64 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0))
65 .WillOnce(QuitMessageLoop()) 65 .WillOnce(QuitMessageLoop())
66 .WillRepeatedly(DoDefault()); 66 .WillRepeatedly(DoDefault());
67 list_->StartUpdating(&observer_); 67 list_->StartUpdating(&observer_);
68 base::RunLoop().Run(); 68 base::RunLoop().Run();
69
70 // Reset the unique_ptr so the list stops refreshing.
71 list_.reset();
69 } 72 }
70 73
71 TEST_F(DesktopMediaListAshTest, OneWindow) { 74 TEST_F(DesktopMediaListAshTest, OneWindow) {
72 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS); 75 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS);
73 76
74 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 77 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
75 78
76 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); 79 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0));
77 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 1)); 80 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 1));
78 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) 81 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0))
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 .WillOnce(QuitMessageLoop()) 116 .WillOnce(QuitMessageLoop())
114 .WillRepeatedly(DoDefault()); 117 .WillRepeatedly(DoDefault());
115 EXPECT_CALL(observer_, OnSourceRemoved(list_.get(), 0)) 118 EXPECT_CALL(observer_, OnSourceRemoved(list_.get(), 0))
116 .WillOnce(QuitMessageLoop()); 119 .WillOnce(QuitMessageLoop());
117 120
118 list_->StartUpdating(&observer_); 121 list_->StartUpdating(&observer_);
119 base::RunLoop().Run(); 122 base::RunLoop().Run();
120 window.reset(); 123 window.reset();
121 base::RunLoop().Run(); 124 base::RunLoop().Run();
122 } 125 }
OLDNEW
« no previous file with comments | « ash/test/ash_test_helper.cc ('k') | components/exo/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698