1 // Copyright 2014 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.
5 #import "ios/web/test/crw_fake_web_controller_observer.h"
7 #import "base/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_vector.h"
9 #include "base/values.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/gtest_mac.h"
12 #include "testing/platform_test.h"
17 class CRWFakeWebControllerObserverTest : public PlatformTest {
19 void SetUp() override {
20 fake_web_controller_observer_.reset([[CRWFakeWebControllerObserver alloc]
21 initWithCommandPrefix:@"test"]);
24 base::scoped_nsobject<CRWFakeWebControllerObserver>
25 fake_web_controller_observer_;
28 // Tests that a CRWFakeWebControllerObserver can be correctly initialized with
30 TEST_F(CRWFakeWebControllerObserverTest, CommandPrefix) {
31 EXPECT_NSEQ(@"test", [fake_web_controller_observer_ commandPrefix]);
34 // Tests that the CRWFakeWebControllerObserver correctly stores a command
36 TEST_F(CRWFakeWebControllerObserverTest, Command) {
38 base::DictionaryValue command;
39 command.SetBoolean("samp", true);
40 [fake_web_controller_observer_ handleCommand:command
43 originURL:GURL("http://google.com")];
45 ScopedVector<base::DictionaryValue>& commands_received =
46 [fake_web_controller_observer_ commandsReceived];
47 EXPECT_EQ(1U, commands_received.size());
49 commands_received[0]->GetBoolean("samp", &samp);