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

Side by Side Diff: webkit/glue/devtools/dom_agent_unittest.cc

Issue 164225: Switch to WebFrame from the WebKit API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/devtools/devtools_rpc_js.h ('k') | webkit/glue/dom_operations.cc » ('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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "config.h" 5 #include "config.h"
6 6
7 #include "CString.h" 7 #include "CString.h"
8 #include "Document.h" 8 #include "Document.h"
9 #include "EventListener.h" 9 #include "EventListener.h"
10 #include "HTMLFrameOwnerElement.h" 10 #include "HTMLFrameOwnerElement.h"
11 #include "Node.h" 11 #include "Node.h"
12 #include "PlatformString.h" 12 #include "PlatformString.h"
13 #include "Text.h" 13 #include "Text.h"
14 #include <wtf/OwnPtr.h> 14 #include <wtf/OwnPtr.h>
15 #undef LOG 15 #undef LOG
16 16
17 #include "base/file_path.h" 17 #include "base/file_path.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "webkit/api/public/WebData.h" 22 #include "webkit/api/public/WebData.h"
23 #include "webkit/api/public/WebFrame.h"
23 #include "webkit/api/public/WebURL.h" 24 #include "webkit/api/public/WebURL.h"
24 #include "webkit/glue/devtools/devtools_mock_rpc.h" 25 #include "webkit/glue/devtools/devtools_mock_rpc.h"
25 #include "webkit/glue/devtools/devtools_rpc.h" 26 #include "webkit/glue/devtools/devtools_rpc.h"
26 #include "webkit/glue/devtools/dom_agent_impl.h" 27 #include "webkit/glue/devtools/dom_agent_impl.h"
27 #include "webkit/glue/dom_operations.h" 28 #include "webkit/glue/dom_operations.h"
28 #include "webkit/glue/glue_util.h" 29 #include "webkit/glue/glue_util.h"
29 #include "webkit/glue/webframe.h"
30 #include "webkit/glue/webframe_impl.h" 30 #include "webkit/glue/webframe_impl.h"
31 #include "webkit/glue/webview.h" 31 #include "webkit/glue/webview.h"
32 #include "webkit/tools/test_shell/test_shell_test.h" 32 #include "webkit/tools/test_shell/test_shell_test.h"
33 33
34 using WebCore::Document; 34 using WebCore::Document;
35 using WebCore::Element; 35 using WebCore::Element;
36 using WebCore::ExceptionCode; 36 using WebCore::ExceptionCode;
37 using WebCore::HTMLFrameOwnerElement; 37 using WebCore::HTMLFrameOwnerElement;
38 using WebCore::Node; 38 using WebCore::Node;
39 using WebCore::String; 39 using WebCore::String;
40 using WebCore::Text; 40 using WebCore::Text;
41 using WebKit::WebFrame;
41 42
42 namespace { 43 namespace {
43 44
44 class MockDomAgentDelegate : public DomAgentDelegateStub, 45 class MockDomAgentDelegate : public DomAgentDelegateStub,
45 public DevToolsMockRpc { 46 public DevToolsMockRpc {
46 public: 47 public:
47 MockDomAgentDelegate() : DomAgentDelegateStub(NULL) { 48 MockDomAgentDelegate() : DomAgentDelegateStub(NULL) {
48 set_delegate(this); 49 set_delegate(this);
49 } 50 }
50 ~MockDomAgentDelegate() {} 51 ~MockDomAgentDelegate() {}
51 }; 52 };
52 53
53 class DomAgentTests : public TestShellTest { 54 class DomAgentTests : public TestShellTest {
54 public: 55 public:
55 DomAgentTests() : ec_(0) {} 56 DomAgentTests() : ec_(0) {}
56 57
57 protected: 58 protected:
58 // testing::Test 59 // testing::Test
59 virtual void SetUp() { 60 virtual void SetUp() {
60 TestShellTest::SetUp(); 61 TestShellTest::SetUp();
61 test_shell_->ResetTestController(); 62 test_shell_->ResetTestController();
62 GURL file_url = net::FilePathToFileURL(data_dir_); 63 GURL file_url = net::FilePathToFileURL(data_dir_);
63 WebFrame* main_frame = test_shell_->webView()->GetMainFrame(); 64 WebFrame* main_frame = test_shell_->webView()->GetMainFrame();
64 main_frame->LoadHTMLString("<html> <head> </head> <body> </body> </html>", 65 main_frame->loadHTMLString("<html> <head> </head> <body> </body> </html>",
65 file_url); 66 file_url);
66 WebFrameImpl* main_frame_impl = static_cast<WebFrameImpl*>(main_frame); 67 WebFrameImpl* main_frame_impl = static_cast<WebFrameImpl*>(main_frame);
67 68
68 document_ = main_frame_impl->frame()->document(); 69 document_ = main_frame_impl->frame()->document();
69 Node* html = document_->documentElement(); 70 Node* html = document_->documentElement();
70 head_ = static_cast<Element*>(html->firstChild()); 71 head_ = static_cast<Element*>(html->firstChild());
71 body_ = static_cast<Element*>(head_->nextSibling()); 72 body_ = static_cast<Element*>(head_->nextSibling());
72 mock_delegate_.set(new MockDomAgentDelegate()); 73 mock_delegate_.set(new MockDomAgentDelegate());
73 dom_agent_.set(new DomAgentImpl(mock_delegate_.get())); 74 dom_agent_.set(new DomAgentImpl(mock_delegate_.get()));
74 dom_agent_->SetDocument(document_.get()); 75 dom_agent_->SetDocument(document_.get());
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 OwnPtr<Value> v(DevToolsRpc::ParseMessage("[8,1,\"DIV\",\"\",[],0]")); 454 OwnPtr<Value> v(DevToolsRpc::ParseMessage("[8,1,\"DIV\",\"\",[],0]"));
454 mock_delegate_->ChildNodeInserted(7, 0, *v.get()); 455 mock_delegate_->ChildNodeInserted(7, 0, *v.get());
455 mock_delegate_->Replay(); 456 mock_delegate_->Replay();
456 457
457 RefPtr<Element> new_div = document_->createElement("DIV", ec_); 458 RefPtr<Element> new_div = document_->createElement("DIV", ec_);
458 inner_body->appendChild(new_div.get(), ec_, false); 459 inner_body->appendChild(new_div.get(), ec_, false);
459 mock_delegate_->Verify(); 460 mock_delegate_->Verify();
460 } 461 }
461 462
462 } // namespace 463 } // namespace
OLDNEW
« no previous file with comments | « webkit/glue/devtools/devtools_rpc_js.h ('k') | webkit/glue/dom_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698