| Index: ios/web/web_state/ui/crw_wk_navigation_states_unittest.mm
|
| diff --git a/ios/web/web_state/ui/crw_wk_navigation_states_unittest.mm b/ios/web/web_state/ui/crw_wk_navigation_states_unittest.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..184de1ccfd61047b1a7f9037a3f66339974496ef
|
| --- /dev/null
|
| +++ b/ios/web/web_state/ui/crw_wk_navigation_states_unittest.mm
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2016 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 "ios/web/web_state/ui/crw_wk_navigation_states.h"
|
| +
|
| +#import <WebKit/WebKit.h>
|
| +
|
| +#import "base/mac/scoped_nsobject.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "testing/platform_test.h"
|
| +
|
| +namespace web {
|
| +
|
| +// Test fixture for CRWWKNavigationStates testing.
|
| +class CRWWKNavigationStatesTest : public PlatformTest {
|
| + protected:
|
| + CRWWKNavigationStatesTest()
|
| + : navigation1_(static_cast<WKNavigation*>([[NSObject alloc] init])),
|
| + navigation2_(static_cast<WKNavigation*>([[NSObject alloc] init])),
|
| + states_([[CRWWKNavigationStates alloc] init]) {}
|
| +
|
| + protected:
|
| + base::scoped_nsobject<WKNavigation> navigation1_;
|
| + base::scoped_nsobject<WKNavigation> navigation2_;
|
| + base::scoped_nsobject<CRWWKNavigationStates> states_;
|
| +};
|
| +
|
| +// Tests |lastAddedNavigation| method.
|
| +TEST_F(CRWWKNavigationStatesTest, LastAddedNavigation) {
|
| + // navigation_1 is the only navigation and it is the latest.
|
| + [states_ addNavigation:navigation1_ forState:WK_NAVIGATION_STATE_REQUESTED];
|
| + EXPECT_EQ(navigation1_, [states_ lastAddedNavigation]);
|
| +
|
| + // navigation_2 is added later and hence the latest.
|
| + [states_ addNavigation:navigation2_ forState:WK_NAVIGATION_STATE_REQUESTED];
|
| + EXPECT_EQ(navigation2_, [states_ lastAddedNavigation]);
|
| +
|
| + // Updating state for existing navigation does not make it the latest.
|
| + [states_ addNavigation:navigation1_ forState:WK_NAVIGATION_STATE_STARTED];
|
| + EXPECT_EQ(navigation2_, [states_ lastAddedNavigation]);
|
| +}
|
| +
|
| +// Tests |stateForNavigation:| method.
|
| +TEST_F(CRWWKNavigationStatesTest, StateForNavigation) {
|
| + [states_ addNavigation:navigation1_ forState:WK_NAVIGATION_STATE_REQUESTED];
|
| + EXPECT_EQ(WK_NAVIGATION_STATE_REQUESTED,
|
| + [states_ stateForNavigation:navigation1_]);
|
| +
|
| + [states_ addNavigation:navigation2_ forState:WK_NAVIGATION_STATE_REQUESTED];
|
| + EXPECT_EQ(WK_NAVIGATION_STATE_REQUESTED,
|
| + [states_ stateForNavigation:navigation2_]);
|
| +
|
| + [states_ addNavigation:navigation1_ forState:WK_NAVIGATION_STATE_STARTED];
|
| + EXPECT_EQ(WK_NAVIGATION_STATE_STARTED,
|
| + [states_ stateForNavigation:navigation1_]);
|
| +}
|
| +
|
| +} // namespace web
|
|
|