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

Side by Side Diff: chrome/browser/ui/views/frame/web_contents_close_handler_unittest.cc

Issue 2851593002: Use ScopedTaskEnvironment instead of MessageLoopForUI in chrome tests. (Closed)
Patch Set: fix-build-error Created 3 years, 7 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/browser/ui/omnibox/clipboard_utils_unittest.cc ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/views/frame/web_contents_close_handler.h" 5 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/test/scoped_task_environment.h"
9 #include "chrome/browser/ui/views/frame/web_contents_close_handler_delegate.h" 9 #include "chrome/browser/ui/views/frame/web_contents_close_handler_delegate.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 class MockWebContentsCloseHandlerDelegate 12 class MockWebContentsCloseHandlerDelegate
13 : public WebContentsCloseHandlerDelegate { 13 : public WebContentsCloseHandlerDelegate {
14 public: 14 public:
15 explicit MockWebContentsCloseHandlerDelegate() 15 explicit MockWebContentsCloseHandlerDelegate()
16 : got_clone_(false), 16 : scoped_task_environment_(
17 got_destroy_(false) { 17 base::test::ScopedTaskEnvironment::MainThreadType::UI),
18 } 18 got_clone_(false),
19 got_destroy_(false) {}
19 ~MockWebContentsCloseHandlerDelegate() override {} 20 ~MockWebContentsCloseHandlerDelegate() override {}
20 21
21 void Clear() { 22 void Clear() {
22 got_clone_ = got_destroy_ = false; 23 got_clone_ = got_destroy_ = false;
23 } 24 }
24 25
25 bool got_clone() const { return got_clone_; } 26 bool got_clone() const { return got_clone_; }
26 void clear_got_clone() { got_clone_ = false; } 27 void clear_got_clone() { got_clone_ = false; }
27 28
28 bool got_destroy() const { return got_destroy_; } 29 bool got_destroy() const { return got_destroy_; }
29 void clear_got_destroy() { got_destroy_ = false; } 30 void clear_got_destroy() { got_destroy_ = false; }
30 31
31 // WebContentsCloseHandlerDelegate: 32 // WebContentsCloseHandlerDelegate:
32 void CloneWebContentsLayer() override { got_clone_ = true; } 33 void CloneWebContentsLayer() override { got_clone_ = true; }
33 void DestroyClonedLayer() override { got_destroy_ = true; } 34 void DestroyClonedLayer() override { got_destroy_ = true; }
34 35
35 private: 36 private:
36 base::MessageLoopForUI message_loop_; 37 base::test::ScopedTaskEnvironment scoped_task_environment_;
37 bool got_clone_; 38 bool got_clone_;
38 bool got_destroy_; 39 bool got_destroy_;
39 40
40 DISALLOW_COPY_AND_ASSIGN(MockWebContentsCloseHandlerDelegate); 41 DISALLOW_COPY_AND_ASSIGN(MockWebContentsCloseHandlerDelegate);
41 }; 42 };
42 43
43 // ----------------------------------------------------------------------------- 44 // -----------------------------------------------------------------------------
44 45
45 class WebContentsCloseHandlerTest : public testing::Test { 46 class WebContentsCloseHandlerTest : public testing::Test {
46 public: 47 public:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 84
84 // Verifies the timer is started after a close. 85 // Verifies the timer is started after a close.
85 TEST_F(WebContentsCloseHandlerTest, DontDestroyImmediatleyAfterCancel) { 86 TEST_F(WebContentsCloseHandlerTest, DontDestroyImmediatleyAfterCancel) {
86 close_handler_.WillCloseAllTabs(); 87 close_handler_.WillCloseAllTabs();
87 close_handler_delegate_.Clear(); 88 close_handler_delegate_.Clear();
88 close_handler_.CloseAllTabsCanceled(); 89 close_handler_.CloseAllTabsCanceled();
89 EXPECT_FALSE(close_handler_delegate_.got_destroy()); 90 EXPECT_FALSE(close_handler_delegate_.got_destroy());
90 EXPECT_FALSE(close_handler_delegate_.got_clone()); 91 EXPECT_FALSE(close_handler_delegate_.got_clone());
91 EXPECT_TRUE(IsTimerRunning()); 92 EXPECT_TRUE(IsTimerRunning());
92 } 93 }
93
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/clipboard_utils_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698