OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "content/public/browser/render_frame_host.h" | 7 #include "content/public/browser/render_frame_host.h" |
8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 commit_number, runner); | 43 commit_number, runner); |
44 quit_closures_.insert(&quit_closure); | 44 quit_closures_.insert(&quit_closure); |
45 runner->Run(); | 45 runner->Run(); |
46 quit_closures_.erase(&quit_closure); | 46 quit_closures_.erase(&quit_closure); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 int GetCommitCount() { return commit_count_; } | 50 int GetCommitCount() { return commit_count_; } |
51 | 51 |
52 private: | 52 private: |
| 53 // RenderViewObserver implementation. |
| 54 void OnDestruct() override { delete this; } |
| 55 |
53 std::set<base::Closure*> quit_closures_; | 56 std::set<base::Closure*> quit_closures_; |
54 int commit_count_; | 57 int commit_count_; |
55 }; | 58 }; |
56 | 59 |
57 class VisualStateTest : public ContentBrowserTest { | 60 class VisualStateTest : public ContentBrowserTest { |
58 public: | 61 public: |
59 VisualStateTest() : callback_count_(0) {} | 62 VisualStateTest() : callback_count_(0) {} |
60 | 63 |
61 void SetUpCommandLine(base::CommandLine* command_line) override { | 64 void SetUpCommandLine(base::CommandLine* command_line) override { |
62 command_line->AppendSwitch(switches::kSingleProcess); | 65 command_line->AppendSwitch(switches::kSingleProcess); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 shell()->web_contents()->GetMainFrame()->InsertVisualStateCallback(base::Bind( | 117 shell()->web_contents()->GetMainFrame()->InsertVisualStateCallback(base::Bind( |
115 &VisualStateTest::InvokeVisualStateCallback, base::Unretained(this))); | 118 &VisualStateTest::InvokeVisualStateCallback, base::Unretained(this))); |
116 | 119 |
117 // Verify that the callback is invoked and a new commit completed. | 120 // Verify that the callback is invoked and a new commit completed. |
118 PostTaskToInProcessRendererAndWait(base::Bind( | 121 PostTaskToInProcessRendererAndWait(base::Bind( |
119 &VisualStateTest::WaitForCommit, base::Unretained(this), &observer, 2)); | 122 &VisualStateTest::WaitForCommit, base::Unretained(this), &observer, 2)); |
120 EXPECT_EQ(1, GetCallbackCount()); | 123 EXPECT_EQ(1, GetCallbackCount()); |
121 } | 124 } |
122 | 125 |
123 } // namespace content | 126 } // namespace content |
OLD | NEW |