blob: 3637fd97e2b5301e2b272aeab3333db55b5e1211 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Cocoa/Cocoa.h>
#import "base/memory/scoped_nsobject.h"
#include "base/message_loop.h"
#import "chrome/browser/ui/cocoa/about_ipc_controller.h"
#include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
#include "content/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#if defined(IPC_MESSAGE_LOG_ENABLED)
namespace {
class AboutIPCControllerTest : public CocoaTest {
public:
virtual void SetUp() {
CocoaTest::SetUp();
ui_message_loop_.reset(new MessageLoopForUI());
ui_thread_.reset(new content::TestBrowserThread(content::BrowserThread::UI,
MessageLoop::current()));
}
virtual void TearDown() {
CocoaTest::TearDown();
ui_thread_.reset(NULL);
}
private:
scoped_ptr<MessageLoopForUI> ui_message_loop_;
scoped_ptr<content::TestBrowserThread> ui_thread_;
};
TEST_F(AboutIPCControllerTest, TestFilter) {
AboutIPCController* controller = [[AboutIPCController alloc] init];
EXPECT_TRUE([controller window]); // force nib load.
IPC::LogData data;
// Make sure generic names do NOT get filtered.
std::string names[] = { "PluginProcessingIsMyLife",
"ViewMsgFoo",
"NPObjectHell" };
for (size_t i = 0; i < arraysize(names); i++) {
data.message_name = names[i];
scoped_nsobject<CocoaLogData> cdata([[CocoaLogData alloc]
initWithLogData:data]);
EXPECT_FALSE([controller filterOut:cdata.get()]);
}
// Flip a checkbox, see it filtered, flip back, all is fine.
data.message_name = "ViewMsgFoo";
scoped_nsobject<CocoaLogData> cdata([[CocoaLogData alloc]
initWithLogData:data]);
[controller setDisplayViewMessages:NO];
EXPECT_TRUE([controller filterOut:cdata.get()]);
[controller setDisplayViewMessages:YES];
EXPECT_FALSE([controller filterOut:cdata.get()]);
[controller close];
}
} // namespace
#endif // IPC_MESSAGE_LOG_ENABLED
|