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

Side by Side Diff: third_party/WebKit/Source/core/page/ContextMenuControllerTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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
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 "core/page/ContextMenuController.h" 5 #include "core/page/ContextMenuController.h"
6 6
7 #include "core/clipboard/DataTransfer.h" 7 #include "core/clipboard/DataTransfer.h"
8 #include "core/events/MouseEvent.h" 8 #include "core/events/MouseEvent.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
11 #include "core/html/HTMLElement.h" 11 #include "core/html/HTMLElement.h"
12 #include "core/testing/DummyPageHolder.h" 12 #include "core/testing/DummyPageHolder.h"
13 #include "platform/ContextMenu.h" 13 #include "platform/ContextMenu.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "wtf/OwnPtr.h" 15 #include <memory>
16 16
17 namespace blink { 17 namespace blink {
18 18
19 class ContextMenuControllerTest : public testing::Test { 19 class ContextMenuControllerTest : public testing::Test {
20 protected: 20 protected:
21 virtual void SetUp() 21 virtual void SetUp()
22 { 22 {
23 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); 23 m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
24 } 24 }
25 25
26 Document& document() const { return m_pageHolder->document(); } 26 Document& document() const { return m_pageHolder->document(); }
27 27
28 void setBodyInnerHTML(const String& htmlContent) 28 void setBodyInnerHTML(const String& htmlContent)
29 { 29 {
30 document().body()->setInnerHTML(htmlContent, ASSERT_NO_EXCEPTION); 30 document().body()->setInnerHTML(htmlContent, ASSERT_NO_EXCEPTION);
31 document().view()->updateAllLifecyclePhases(); 31 document().view()->updateAllLifecyclePhases();
32 } 32 }
33 33
34 private: 34 private:
35 OwnPtr<DummyPageHolder> m_pageHolder; 35 std::unique_ptr<DummyPageHolder> m_pageHolder;
36 }; 36 };
37 37
38 TEST_F(ContextMenuControllerTest, TestCustomMenu) 38 TEST_F(ContextMenuControllerTest, TestCustomMenu)
39 { 39 {
40 document().settings()->setScriptEnabled(true); 40 document().settings()->setScriptEnabled(true);
41 // Load the the test page. 41 // Load the the test page.
42 setBodyInnerHTML( 42 setBodyInnerHTML(
43 "<button id=\"button_id\" contextmenu=\"menu_id\" style=\"height: 100px; width: 100px;\">" 43 "<button id=\"button_id\" contextmenu=\"menu_id\" style=\"height: 100px; width: 100px;\">"
44 "<menu type=\"context\" id=\"menu_id\">" 44 "<menu type=\"context\" id=\"menu_id\">"
45 "<menuitem label=\"Item1\" onclick='document.title = \"Title 1\";'>" 45 "<menuitem label=\"Item1\" onclick='document.title = \"Title 1\";'>"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 EXPECT_STREQ("Title 7 checked", document().title().utf8().data()); 102 EXPECT_STREQ("Title 7 checked", document().title().utf8().data());
103 document().page()->contextMenuController().contextMenuItemSelected(&items[4] ); 103 document().page()->contextMenuController().contextMenuItemSelected(&items[4] );
104 EXPECT_STREQ("Title 7 not checked", document().title().utf8().data()); 104 EXPECT_STREQ("Title 7 not checked", document().title().utf8().data());
105 document().page()->contextMenuController().contextMenuItemSelected(&items[5] ); 105 document().page()->contextMenuController().contextMenuItemSelected(&items[5] );
106 EXPECT_STREQ("Title 8 not checked and Title 9 checked", document().title().u tf8().data()); 106 EXPECT_STREQ("Title 8 not checked and Title 9 checked", document().title().u tf8().data());
107 document().page()->contextMenuController().contextMenuItemSelected(&items[7] ); 107 document().page()->contextMenuController().contextMenuItemSelected(&items[7] );
108 EXPECT_STREQ("Title 10 not checked and Title 8 checked", document().title(). utf8().data()); 108 EXPECT_STREQ("Title 10 not checked and Title 8 checked", document().title(). utf8().data());
109 } 109 }
110 110
111 } // namespace blink 111 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/ContextMenuController.cpp ('k') | third_party/WebKit/Source/core/page/DragController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698