| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <objc/runtime.h> | 5 #import <objc/runtime.h> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #import "ios/web/web_state/ui/crw_web_controller.h" | 34 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 35 #import "ios/web/web_state/web_state_impl.h" | 35 #import "ios/web/web_state/web_state_impl.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| 37 #include "testing/gtest_mac.h" | 37 #include "testing/gtest_mac.h" |
| 38 #include "testing/platform_test.h" | 38 #include "testing/platform_test.h" |
| 39 #import "third_party/ocmock/OCMock/OCMock.h" | 39 #import "third_party/ocmock/OCMock/OCMock.h" |
| 40 #include "third_party/ocmock/gtest_support.h" | 40 #include "third_party/ocmock/gtest_support.h" |
| 41 | 41 |
| 42 using web::WebStateImpl; | 42 using web::WebStateImpl; |
| 43 | 43 |
| 44 // For some of the unit tests, we need to make sure the session is saved | |
| 45 // immediately so we can read it back in to verify various attributes. This | |
| 46 // is not a situation we normally expect to be in because we never | |
| 47 // want the session being saved on the main thread in the production app. | |
| 48 // We could expose this as part of the service's public API, but again that | |
| 49 // might encourage use where we don't want it. As a result, just use the | |
| 50 // known private-for-testing method directly. | |
| 51 @interface SessionServiceIOS (Testing) | |
| 52 - (void)performSaveWindow:(SessionWindowIOS*)window | |
| 53 toDirectory:(NSString*)directory; | |
| 54 @end | |
| 55 | 44 |
| 56 @interface TabModel (VisibleForTesting) | 45 @interface TabModel (VisibleForTesting) |
| 57 - (SessionWindowIOS*)windowForSavingSession; | 46 - (SessionWindowIOS*)windowForSavingSession; |
| 58 @end | 47 @end |
| 59 | 48 |
| 60 // Defines a TabModelObserver for use in unittests. This class can be used to | 49 // Defines a TabModelObserver for use in unittests. This class can be used to |
| 61 // test if an observer method was called or not. | 50 // test if an observer method was called or not. |
| 62 @interface TabModelObserverPong : NSObject<TabModelObserver> { | 51 @interface TabModelObserverPong : NSObject<TabModelObserver> { |
| 63 // TODO(crbug.com/661989): Add tests for the other observer methods. | 52 // TODO(crbug.com/661989): Add tests for the other observer methods. |
| 64 BOOL tabMovedWasCalled_; | 53 BOOL tabMovedWasCalled_; |
| (...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:2]]); | 1146 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:2]]); |
| 1158 EXPECT_EQ([tab_model_ tabAtIndex:2], | 1147 EXPECT_EQ([tab_model_ tabAtIndex:2], |
| 1159 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]); | 1148 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]); |
| 1160 | 1149 |
| 1161 // Clean up. | 1150 // Clean up. |
| 1162 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath | 1151 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath |
| 1163 error:nullptr]); | 1152 error:nullptr]); |
| 1164 } | 1153 } |
| 1165 | 1154 |
| 1166 } // anonymous namespace | 1155 } // anonymous namespace |
| OLD | NEW |