1// Copyright (c) 2009 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/automation/chrome_frame_automation_provider.h"
6#include "chrome/test/testing_browser_process.h"
7#include "chrome/test/testing_browser_process_test.h"
8#include "content/browser/browser_thread.h"
9#include "testing/gmock/include/gmock/gmock.h"
10#include "testing/gtest/include/gtest/gtest.h"
11
12class MockChromeFrameAutomationProvider
13    : public ChromeFrameAutomationProvider {
14 public:
15  explicit MockChromeFrameAutomationProvider(Profile* profile)
16      : ChromeFrameAutomationProvider(profile) {}
17
18  virtual ~MockChromeFrameAutomationProvider() {}
19
20  MOCK_METHOD1(OnUnhandledMessage,
21               void (const IPC::Message& message));  // NOLINT
22};
23
24typedef TestingBrowserProcessTest AutomationProviderTest;
25
26TEST_F(AutomationProviderTest, TestInvalidChromeFrameMessage) {
27  MessageLoop message_loop;
28  BrowserThread ui_thread(BrowserThread::UI, &message_loop);
29
30  IPC::Message bad_msg(1, -1, IPC::Message::PRIORITY_NORMAL);
31
32  scoped_refptr<MockChromeFrameAutomationProvider>
33      mock(new MockChromeFrameAutomationProvider(NULL));
34
35  EXPECT_CALL(*mock, OnUnhandledMessage(testing::Property(&IPC::Message::type,
36                                        -1))).Times(1);
37  mock->OnMessageReceived(bad_msg);
38}
39
40