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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationAvailabilityTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. 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 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 "modules/presentation/PresentationAvailability.h" 5 #include "modules/presentation/PresentationAvailability.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/page/Page.h" 10 #include "core/page/Page.h"
11 #include "core/testing/DummyPageHolder.h" 11 #include "core/testing/DummyPageHolder.h"
12 #include "platform/testing/URLTestHelpers.h" 12 #include "platform/testing/URLTestHelpers.h"
13 #include "platform/weborigin/KURL.h" 13 #include "platform/weborigin/KURL.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include <memory>
15 #include <v8.h> 16 #include <v8.h>
16 17
17 namespace blink { 18 namespace blink {
18 namespace { 19 namespace {
19 20
20 class PresentationAvailabilityTest : public ::testing::Test { 21 class PresentationAvailabilityTest : public ::testing::Test {
21 public: 22 public:
22 PresentationAvailabilityTest() 23 PresentationAvailabilityTest()
23 : m_scope(v8::Isolate::GetCurrent()) 24 : m_scope(v8::Isolate::GetCurrent())
24 , m_page(DummyPageHolder::create()) 25 , m_page(DummyPageHolder::create())
25 { 26 {
26 } 27 }
27 28
28 void SetUp() override 29 void SetUp() override
29 { 30 {
30 m_scope.getScriptState()->setExecutionContext(&m_page->document()); 31 m_scope.getScriptState()->setExecutionContext(&m_page->document());
31 } 32 }
32 33
33 Page& page() { return m_page->page(); } 34 Page& page() { return m_page->page(); }
34 LocalFrame& frame() { return m_page->frame(); } 35 LocalFrame& frame() { return m_page->frame(); }
35 ScriptState* getScriptState() { return m_scope.getScriptState(); } 36 ScriptState* getScriptState() { return m_scope.getScriptState(); }
36 37
37 private: 38 private:
38 V8TestingScope m_scope; 39 V8TestingScope m_scope;
39 OwnPtr<DummyPageHolder> m_page; 40 std::unique_ptr<DummyPageHolder> m_page;
40 }; 41 };
41 42
42 TEST_F(PresentationAvailabilityTest, NoPageVisibilityChangeAfterDetach) 43 TEST_F(PresentationAvailabilityTest, NoPageVisibilityChangeAfterDetach)
43 { 44 {
44 const KURL url = URLTestHelpers::toKURL("https://example.com"); 45 const KURL url = URLTestHelpers::toKURL("https://example.com");
45 Persistent<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(g etScriptState()); 46 Persistent<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(g etScriptState());
46 Persistent<PresentationAvailability> availability = PresentationAvailability ::take(resolver, url, false); 47 Persistent<PresentationAvailability> availability = PresentationAvailability ::take(resolver, url, false);
47 48
48 // These two calls should not crash. 49 // These two calls should not crash.
49 frame().detach(FrameDetachType::Remove); 50 frame().detach(FrameDetachType::Remove);
50 page().setVisibilityState(PageVisibilityStateHidden, false); 51 page().setVisibilityState(PageVisibilityStateHidden, false);
51 } 52 }
52 53
53 } // anonymous namespace 54 } // anonymous namespace
54 } // namespace blink 55 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698