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

Side by Side Diff: chrome/browser/visitedlink/visitedlink_unittest.cc

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <cstdio> 5 #include <cstdio>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/process_util.h" 12 #include "base/process_util.h"
13 #include "base/shared_memory.h" 13 #include "base/shared_memory.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" 15 #include "chrome/browser/visitedlink/visitedlink_event_listener.h"
16 #include "chrome/browser/visitedlink/visitedlink_master.h" 16 #include "chrome/browser/visitedlink/visitedlink_master.h"
17 #include "chrome/common/render_messages.h" 17 #include "chrome/common/render_messages.h"
18 #include "chrome/renderer/visitedlink_slave.h" 18 #include "chrome/renderer/visitedlink_slave.h"
19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
20 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
21 #include "content/browser/renderer_host/browser_render_process_host.h" 21 #include "content/browser/renderer_host/render_process_host_impl.h"
22 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
24 #include "content/test/test_browser_thread.h" 24 #include "content/test/test_browser_thread.h"
25 #include "googleurl/src/gurl.h" 25 #include "googleurl/src/gurl.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 27
28 using content::BrowserThread; 28 using content::BrowserThread;
29 29
30 namespace { 30 namespace {
31 31
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 int reset_event_count() const { return reset_event_count_; } 488 int reset_event_count() const { return reset_event_count_; }
489 489
490 private: 490 private:
491 int add_count_; 491 int add_count_;
492 int add_event_count_; 492 int add_event_count_;
493 int reset_event_count_; 493 int reset_event_count_;
494 scoped_ptr<VisitedLinkEventListener> event_listener_; 494 scoped_ptr<VisitedLinkEventListener> event_listener_;
495 scoped_ptr<VisitedLinkMaster> visited_link_master_; 495 scoped_ptr<VisitedLinkMaster> visited_link_master_;
496 }; 496 };
497 497
498 // Stub out as little as possible, borrowing from BrowserRenderProcessHost. 498 // Stub out as little as possible, borrowing from RenderProcessHost.
499 class VisitRelayingRenderProcessHost : public BrowserRenderProcessHost { 499 class VisitRelayingRenderProcessHost : public RenderProcessHostImpl {
jam 2011/11/16 22:10:19 this will have to change (in the future), since we
ananta 2011/11/17 13:34:45 Yes. We can mock out the remaining RPH methods or
500 public: 500 public:
501 explicit VisitRelayingRenderProcessHost( 501 explicit VisitRelayingRenderProcessHost(
502 content::BrowserContext* browser_context) 502 content::BrowserContext* browser_context)
503 : BrowserRenderProcessHost(browser_context) { 503 : RenderProcessHostImpl(browser_context) {
504 content::NotificationService::current()->Notify( 504 content::NotificationService::current()->Notify(
505 content::NOTIFICATION_RENDERER_PROCESS_CREATED, 505 content::NOTIFICATION_RENDERER_PROCESS_CREATED,
506 content::Source<RenderProcessHost>(this), 506 content::Source<RenderProcessHost>(this),
507 content::NotificationService::NoDetails()); 507 content::NotificationService::NoDetails());
508 } 508 }
509 virtual ~VisitRelayingRenderProcessHost() { 509 virtual ~VisitRelayingRenderProcessHost() {
510 content::NotificationService::current()->Notify( 510 content::NotificationService::current()->Notify(
511 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 511 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
512 content::Source<RenderProcessHost>(this), 512 content::Source<RenderProcessHost>(this),
513 content::NotificationService::NoDetails()); 513 content::NotificationService::NoDetails());
(...skipping 11 matching lines...) Expand all
525 525
526 virtual bool WaitForPaintMsg(int render_widget_id, 526 virtual bool WaitForPaintMsg(int render_widget_id,
527 const base::TimeDelta& max_delay, 527 const base::TimeDelta& max_delay,
528 IPC::Message* msg) { 528 IPC::Message* msg) {
529 return false; 529 return false;
530 } 530 }
531 531
532 virtual bool Send(IPC::Message* msg) { 532 virtual bool Send(IPC::Message* msg) {
533 VisitCountingProfile* counting_profile = 533 VisitCountingProfile* counting_profile =
534 static_cast<VisitCountingProfile*>( 534 static_cast<VisitCountingProfile*>(
535 Profile::FromBrowserContext(browser_context())); 535 Profile::FromBrowserContext(GetBrowserContext()));
536 536
537 if (msg->type() == ChromeViewMsg_VisitedLink_Add::ID) { 537 if (msg->type() == ChromeViewMsg_VisitedLink_Add::ID) {
538 void* iter = NULL; 538 void* iter = NULL;
539 std::vector<uint64> fingerprints; 539 std::vector<uint64> fingerprints;
540 CHECK(IPC::ReadParam(msg, &iter, &fingerprints)); 540 CHECK(IPC::ReadParam(msg, &iter, &fingerprints));
541 counting_profile->CountAddEvent(fingerprints.size()); 541 counting_profile->CountAddEvent(fingerprints.size());
542 } else if (msg->type() == ChromeViewMsg_VisitedLink_Reset::ID) { 542 } else if (msg->type() == ChromeViewMsg_VisitedLink_Reset::ID) {
543 counting_profile->CountResetEvent(); 543 counting_profile->CountResetEvent();
544 } 544 }
545 545
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 EXPECT_EQ(1, profile()->add_event_count()); 720 EXPECT_EQ(1, profile()->add_event_count());
721 EXPECT_EQ(0, profile()->reset_event_count()); 721 EXPECT_EQ(0, profile()->reset_event_count());
722 722
723 // Activate the tab. 723 // Activate the tab.
724 rvh()->WasRestored(); 724 rvh()->WasRestored();
725 725
726 // We should have only one more reset event. 726 // We should have only one more reset event.
727 EXPECT_EQ(1, profile()->add_event_count()); 727 EXPECT_EQ(1, profile()->add_event_count());
728 EXPECT_EQ(1, profile()->reset_event_count()); 728 EXPECT_EQ(1, profile()->reset_event_count());
729 } 729 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698