| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "ui/base/ime/win/tsf_text_store.h" | 5 #include "ui/base/ime/win/tsf_text_store.h" | 
| 6 | 6 | 
| 7 #include "base/win/scoped_com_initializer.h" | 7 #include "base/win/scoped_com_initializer.h" | 
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" | 
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" | 
| 10 #include "ui/base/ime/text_input_client.h" | 10 #include "ui/base/ime/text_input_client.h" | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 26   MOCK_METHOD0(ClearCompositionText, void()); | 26   MOCK_METHOD0(ClearCompositionText, void()); | 
| 27   MOCK_METHOD1(InsertText, void(const string16&)); | 27   MOCK_METHOD1(InsertText, void(const string16&)); | 
| 28   MOCK_METHOD2(InsertChar, void(char16, int)); | 28   MOCK_METHOD2(InsertChar, void(char16, int)); | 
| 29   MOCK_CONST_METHOD0(GetAttachedWindow, gfx::NativeWindow()); | 29   MOCK_CONST_METHOD0(GetAttachedWindow, gfx::NativeWindow()); | 
| 30   MOCK_CONST_METHOD0(GetTextInputType, ui::TextInputType()); | 30   MOCK_CONST_METHOD0(GetTextInputType, ui::TextInputType()); | 
| 31   MOCK_CONST_METHOD0(GetTextInputMode, ui::TextInputMode()); | 31   MOCK_CONST_METHOD0(GetTextInputMode, ui::TextInputMode()); | 
| 32   MOCK_CONST_METHOD0(CanComposeInline, bool()); | 32   MOCK_CONST_METHOD0(CanComposeInline, bool()); | 
| 33   MOCK_METHOD0(GetCaretBounds, gfx::Rect()); | 33   MOCK_METHOD0(GetCaretBounds, gfx::Rect()); | 
| 34   MOCK_METHOD2(GetCompositionCharacterBounds, bool(uint32, gfx::Rect*)); | 34   MOCK_METHOD2(GetCompositionCharacterBounds, bool(uint32, gfx::Rect*)); | 
| 35   MOCK_METHOD0(HasCompositionText, bool()); | 35   MOCK_METHOD0(HasCompositionText, bool()); | 
| 36   MOCK_METHOD1(GetTextRange, bool(ui::Range*)); | 36   MOCK_METHOD1(GetTextRange, bool(gfx::Range*)); | 
| 37   MOCK_METHOD1(GetCompositionTextRange, bool(ui::Range*)); | 37   MOCK_METHOD1(GetCompositionTextRange, bool(gfx::Range*)); | 
| 38   MOCK_METHOD1(GetSelectionRange, bool(ui::Range*)); | 38   MOCK_METHOD1(GetSelectionRange, bool(gfx::Range*)); | 
| 39   MOCK_METHOD1(SetSelectionRange, bool(const ui::Range&)); | 39   MOCK_METHOD1(SetSelectionRange, bool(const gfx::Range&)); | 
| 40   MOCK_METHOD1(DeleteRange, bool(const ui::Range&)); | 40   MOCK_METHOD1(DeleteRange, bool(const gfx::Range&)); | 
| 41   MOCK_METHOD2(GetTextFromRange, bool(const ui::Range&, string16*)); | 41   MOCK_METHOD2(GetTextFromRange, bool(const gfx::Range&, string16*)); | 
| 42   MOCK_METHOD0(OnInputMethodChanged, void()); | 42   MOCK_METHOD0(OnInputMethodChanged, void()); | 
| 43   MOCK_METHOD1(ChangeTextDirectionAndLayoutAlignment, | 43   MOCK_METHOD1(ChangeTextDirectionAndLayoutAlignment, | 
| 44                bool(base::i18n::TextDirection)); | 44                bool(base::i18n::TextDirection)); | 
| 45   MOCK_METHOD2(ExtendSelectionAndDelete, void(size_t, size_t)); | 45   MOCK_METHOD2(ExtendSelectionAndDelete, void(size_t, size_t)); | 
| 46   MOCK_METHOD1(EnsureCaretInRect, void(const gfx::Rect&)); | 46   MOCK_METHOD1(EnsureCaretInRect, void(const gfx::Rect&)); | 
| 47 }; | 47 }; | 
| 48 | 48 | 
| 49 class MockStoreACPSink : public ITextStoreACPSink { | 49 class MockStoreACPSink : public ITextStoreACPSink { | 
| 50  public: | 50  public: | 
| 51   MockStoreACPSink() : ref_count_(0) { | 51   MockStoreACPSink() : ref_count_(0) { | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 132       : text_store_(text_store) { | 132       : text_store_(text_store) { | 
| 133     CHECK(text_store_); | 133     CHECK(text_store_); | 
| 134   } | 134   } | 
| 135   virtual ~TSFTextStoreTestCallback() {} | 135   virtual ~TSFTextStoreTestCallback() {} | 
| 136 | 136 | 
| 137  protected: | 137  protected: | 
| 138   // Accessors to the internal state of TSFTextStore. | 138   // Accessors to the internal state of TSFTextStore. | 
| 139   bool* edit_flag() { return &text_store_->edit_flag_; } | 139   bool* edit_flag() { return &text_store_->edit_flag_; } | 
| 140   string16* string_buffer() { return &text_store_->string_buffer_; } | 140   string16* string_buffer() { return &text_store_->string_buffer_; } | 
| 141   size_t* committed_size() { return &text_store_->committed_size_; } | 141   size_t* committed_size() { return &text_store_->committed_size_; } | 
| 142   Range* selection() { return &text_store_->selection_; } | 142   gfx::Range* selection() { return &text_store_->selection_; } | 
| 143   CompositionUnderlines* composition_undelines() { | 143   CompositionUnderlines* composition_undelines() { | 
| 144     return &text_store_->composition_undelines_; | 144     return &text_store_->composition_undelines_; | 
| 145   } | 145   } | 
| 146 | 146 | 
| 147   void SetInternalState(const string16& new_string_buffer, | 147   void SetInternalState(const string16& new_string_buffer, | 
| 148                         LONG new_committed_size, LONG new_selection_start, | 148                         LONG new_committed_size, LONG new_selection_start, | 
| 149                         LONG new_selection_end) { | 149                         LONG new_selection_end) { | 
| 150     ASSERT_LE(0, new_committed_size); | 150     ASSERT_LE(0, new_committed_size); | 
| 151     ASSERT_LE(new_committed_size, new_selection_start); | 151     ASSERT_LE(new_committed_size, new_selection_start); | 
| 152     ASSERT_LE(new_selection_start, new_selection_end); | 152     ASSERT_LE(new_selection_start, new_selection_end); | 
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1139                  &GetTextExtTestCallback::GetCompositionCharacterBounds)); | 1139                  &GetTextExtTestCallback::GetCompositionCharacterBounds)); | 
| 1140 | 1140 | 
| 1141   EXPECT_CALL(*sink_, OnLockGranted(_)) | 1141   EXPECT_CALL(*sink_, OnLockGranted(_)) | 
| 1142       .WillOnce(Invoke(&callback, &GetTextExtTestCallback::LockGranted)); | 1142       .WillOnce(Invoke(&callback, &GetTextExtTestCallback::LockGranted)); | 
| 1143 | 1143 | 
| 1144   HRESULT result; | 1144   HRESULT result; | 
| 1145   EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READ, &result)); | 1145   EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READ, &result)); | 
| 1146 } | 1146 } | 
| 1147 | 1147 | 
| 1148 }  // namespace ui | 1148 }  // namespace ui | 
| OLD | NEW | 
|---|