| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/weak_ptr.h" |
| 6 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 7 #include "content/browser/intents/intent_injector.h" | 8 #include "content/browser/intents/intent_injector.h" |
| 8 #include "content/browser/intents/internal_web_intents_dispatcher.h" | 9 #include "content/browser/intents/internal_web_intents_dispatcher.h" |
| 9 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
| 10 #include "content/browser/web_contents/test_web_contents.h" | 11 #include "content/browser/web_contents/test_web_contents.h" |
| 11 #include "content/common/intents_messages.h" | 12 #include "content/common/intents_messages.h" |
| 12 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
| 13 #include "content/test/web_contents_tester.h" | 14 #include "content/test/web_contents_tester.h" |
| 14 #include "content/test/mock_render_process_host.h" | 15 #include "content/test/mock_render_process_host.h" |
| 15 #include "ipc/ipc_channel.h" | 16 #include "ipc/ipc_channel.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 std::string()); | 82 std::string()); |
| 82 ASSERT_TRUE(contents()->cross_navigation_pending()); | 83 ASSERT_TRUE(contents()->cross_navigation_pending()); |
| 83 ASSERT_TRUE(pending_rvh()); | 84 ASSERT_TRUE(pending_rvh()); |
| 84 injector->RenderViewCreated(pending_test_rvh()); | 85 injector->RenderViewCreated(pending_test_rvh()); |
| 85 | 86 |
| 86 // The injector is still operating on the WebContents with the ddd.com | 87 // The injector is still operating on the WebContents with the ddd.com |
| 87 // initial page, so no intent data is sent to this new renderer. | 88 // initial page, so no intent data is sent to this new renderer. |
| 88 EXPECT_TRUE(NULL == process()->sink().GetFirstMessageMatching( | 89 EXPECT_TRUE(NULL == process()->sink().GetFirstMessageMatching( |
| 89 IntentsMsg_SetWebIntentData::ID)); | 90 IntentsMsg_SetWebIntentData::ID)); |
| 90 } | 91 } |
| 92 |
| 93 TEST_F(IntentInjectorTest, AbandonDeletes) { |
| 94 IntentInjector* injector = new IntentInjector(web_contents()); |
| 95 |
| 96 base::WeakPtr<IntentInjector> weak_injector = |
| 97 injector->weak_factory_.GetWeakPtr(); |
| 98 EXPECT_FALSE(weak_injector.get() == NULL); |
| 99 weak_injector->Abandon(); |
| 100 EXPECT_TRUE(weak_injector.get() == NULL); |
| 101 |
| 102 // Sending a message will both auto-delete |dispatcher_| to clean up and |
| 103 // verify that messages don't get sent to the (now deleted) |injector|. |
| 104 dispatcher_->SendReplyMessage( |
| 105 webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED, string16()); |
| 106 |
| 107 } |
| OLD | NEW |