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

Side by Side Diff: content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc

Issue 2038843003: bluetooth: Don't call methods of WebContentsImpl while it's being destroyed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix dcheck 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/bluetooth/frame_connected_bluetooth_devices.h" 5 #include "content/browser/bluetooth/frame_connected_bluetooth_devices.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "content/test/test_render_view_host.h" 9 #include "content/test/test_render_view_host.h"
10 #include "content/test/test_web_contents.h" 10 #include "content/test/test_web_contents.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 map0_.reset(); 347 map0_.reset();
348 348
349 // WebContents should still be connected because of map1_. 349 // WebContents should still be connected because of map1_.
350 EXPECT_TRUE(contents()->IsConnectedToBluetoothDevice()); 350 EXPECT_TRUE(contents()->IsConnectedToBluetoothDevice());
351 351
352 map1_.reset(); 352 map1_.reset();
353 353
354 EXPECT_FALSE(contents()->IsConnectedToBluetoothDevice()); 354 EXPECT_FALSE(contents()->IsConnectedToBluetoothDevice());
355 } 355 }
356 356
357 TEST_F(FrameConnectedBluetoothDevicesTest, WebContentsImpl_Destruction) {
Jeffrey Yasskin 2016/06/06 16:55:36 It's good to write the overall meaning of the test
ortuno 2016/06/06 18:25:16 Done.
358 // Tests that we don't crash when FrameConnectedBluetoothDeviceTest is
Jeffrey Yasskin 2016/06/06 16:55:36 Did you mean FrameConnectedBluetoothDevices here?
ortuno 2016/06/06 18:25:16 Done.
359 // destroyed while WebContentsImpl is being destroyed.
Jeffrey Yasskin 2016/06/06 16:55:36 It's not just "while", right? It's when FrameConne
ortuno 2016/06/06 18:25:16 Done.
360
361 map0_->Insert(kDeviceId0, GetConnection(kDeviceAddress0));
362 // A FrameConnectedBluetoothDevices instance is usually owned by a
363 // WebBluetoothServiceImpl instance which is owned by a RenderFrameHost which
364 // is owned by WebContentsImpl. In order to avoid adding unnecessary
365 // complexity to WebBluetoothServiceImpl just so we can perform this test we
366 // add the map directly to a frame and then delete WebContents.
367 contents()->GetMainFrame()->SetFrameConnectedBluetoothDevices(
368 std::move(map0_));
369 DeleteContents();
370 }
371
357 } // namespace content 372 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698