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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_WEB_VIEW_TEST_FRAME_TREE_DELEGATE_H_
6 #define COMPONENTS_WEB_VIEW_TEST_FRAME_TREE_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/web_view/frame_tree_delegate.h"
17 class ApplicationImpl
;
22 class TestFrameTreeDelegate
: public FrameTreeDelegate
{
24 explicit TestFrameTreeDelegate(mojo::ApplicationImpl
* app
);
25 ~TestFrameTreeDelegate() override
;
27 mojo::ApplicationImpl
* app() { return app_
; }
29 // Runs a message loop until DidCreateFrame() is called, returning the
30 // Frame supplied to DidCreateFrame().
31 Frame
* WaitForCreateFrame();
33 // Waits for DidDestroyFrame() to be called with |frame|.
34 void WaitForDestroyFrame(Frame
* frame
);
36 // Waits for OnViewEmbeddedInFrameDisconnected() to be called with |frame|.
37 void WaitForFrameDisconnected(Frame
* frame
);
39 // TestFrameTreeDelegate:
40 scoped_ptr
<FrameUserData
> CreateUserDataForNewFrame(
41 mojom::FrameClientPtr frame_client
) override
;
42 bool CanPostMessageEventToFrame(const Frame
* source
,
44 mojom::HTMLMessageEvent
* event
) override
;
45 void LoadingStateChanged(bool loading
, double progress
) override
;
46 void TitleChanged(const mojo::String
& title
) override
;
47 void NavigateTopLevel(Frame
* source
, mojo::URLRequestPtr request
) override
;
48 void CanNavigateFrame(Frame
* target
,
49 mojo::URLRequestPtr request
,
50 const CanNavigateFrameCallback
& callback
) override
;
51 void DidStartNavigation(Frame
* frame
) override
;
52 void DidCommitProvisionalLoad(Frame
* frame
) override
;
53 void DidCreateFrame(Frame
* frame
) override
;
54 void DidDestroyFrame(Frame
* frame
) override
;
55 void OnViewEmbeddedInFrameDisconnected(Frame
* frame
) override
;
58 bool is_waiting() const { return run_loop_
.get(); }
60 mojo::ApplicationImpl
* app_
;
61 bool waiting_for_create_frame_
;
62 Frame
* waiting_for_destroy_frame_
;
63 scoped_ptr
<base::RunLoop
> run_loop_
;
64 Frame
* most_recent_frame_
;
65 Frame
* waiting_for_frame_disconnected_
;
67 DISALLOW_COPY_AND_ASSIGN(TestFrameTreeDelegate
);
70 } // namespace web_view
72 #endif // COMPONENTS_WEB_VIEW_TEST_FRAME_TREE_DELEGATE_H_