| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #import "ios/web/test/crw_fake_web_controller_observer.h" | |
| 6 | |
| 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" | |
| 13 #include "url/gurl.h" | |
| 14 | |
| 15 namespace web { | |
| 16 namespace { | |
| 17 class CRWFakeWebControllerObserverTest : public PlatformTest { | |
| 18 public: | |
| 19 void SetUp() override { | |
| 20 fake_web_controller_observer_.reset([[CRWFakeWebControllerObserver alloc] | |
| 21 initWithCommandPrefix:@"test"]); | |
| 22 } | |
| 23 protected: | |
| 24 base::scoped_nsobject<CRWFakeWebControllerObserver> | |
| 25 fake_web_controller_observer_; | |
| 26 }; | |
| 27 | |
| 28 // Tests that a CRWFakeWebControllerObserver can be correctly initialized with | |
| 29 // a command prefix. | |
| 30 TEST_F(CRWFakeWebControllerObserverTest, CommandPrefix) { | |
| 31 EXPECT_NSEQ(@"test", [fake_web_controller_observer_ commandPrefix]); | |
| 32 } | |
| 33 | |
| 34 // Tests that the CRWFakeWebControllerObserver correctly stores a command | |
| 35 // received. | |
| 36 TEST_F(CRWFakeWebControllerObserverTest, Command) { | |
| 37 // Arbitrary values. | |
| 38 base::DictionaryValue command; | |
| 39 command.SetBoolean("samp", true); | |
| 40 [fake_web_controller_observer_ handleCommand:command | |
| 41 webController:nil | |
| 42 userIsInteracting:NO | |
| 43 originURL:GURL("http://google.com")]; | |
| 44 | |
| 45 ScopedVector<base::DictionaryValue>& commands_received = | |
| 46 [fake_web_controller_observer_ commandsReceived]; | |
| 47 EXPECT_EQ(1U, commands_received.size()); | |
| 48 bool samp = false; | |
| 49 commands_received[0]->GetBoolean("samp", &samp); | |
| 50 EXPECT_TRUE(samp); | |
| 51 } | |
| 52 | |
| 53 } // namespace | |
| 54 } // namespace web | |
| OLD | NEW |