• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "gtest/gtest.h"
16 #include "ui_driver.h"
17 #include "ui_model.h"
18 #include "mock_element_node_iterator.h"
19 #include "mock_controller.h"
20 
21 using namespace OHOS::uitest;
22 using namespace std;
23 
24 // test fixture
25 
26 class UiDriverTest : public testing::Test {
27 protected:
SetUp()28     void SetUp() override
29     {
30         auto mockController = make_unique<MockController>();
31         controller_ = mockController.get();
32         UiDriver::RegisterController(move(mockController));
33         driver_ = make_unique<UiDriver>();
34     }
35 
TearDown()36     void TearDown() override
37     {
38         controller_ = nullptr;
39     }
40 
41     MockController *controller_ = nullptr;
42     unique_ptr<UiDriver> driver_ = nullptr;
43     UiOpArgs opt_;
44 
45     ~UiDriverTest() override = default;
46 };
47 
TEST_F(UiDriverTest,normalInteraction)48 TEST_F(UiDriverTest, normalInteraction)
49 {
50     std::string nodeJson = R"(
51         {
52             "attributes":{
53                 "windowId":"12",
54 				"bundleName":"test1",
55                 "componentType":"List",
56                 "accessibilityId":"1",
57                 "content":"Text List",
58                 "rectInScreen":"30,60,10,120"
59             },
60             "children":[
61                 {
62                     "attributes":{
63                     "windowId":"12",
64                     "bundleName":"test1",
65                     "componentType":"Text",
66                     "accessibilityId":"100",
67                     "content":"USB",
68                     "rectInScreen":"30,60,10,20"
69                     },
70                     "children":[]
71                 }
72             ]
73         }
74     )";
75 
76     std::vector<MockAccessibilityElementInfo> eles =
77         MockElementNodeIterator::ConstructIteratorByJson(nodeJson)->elementInfoLists_;
78 
79     Window w1{12};
80     w1.windowLayer_ = 2;
81     w1.bounds_ = Rect{0, 100, 0, 120};
82 
83     controller_->AddWindowsAndNode(w1, eles);
84 
85     auto error = ApiCallErr(NO_ERROR);
86     auto selector = WidgetSelector();
87     auto matcher = WidgetMatchModel(UiAttr::TEXT, "USB", EQ);
88     selector.AddMatcher(matcher);
89     vector<unique_ptr<Widget>> widgets;
90     selector.SetWantMulti(false);
91     driver_->FindWidgets(selector, widgets, error, true);
92 
93     ASSERT_EQ(1, widgets.size());
94     // perform interactions
95     auto key = Back();
96     driver_->TriggerKey(key, opt_, error);
97     ASSERT_EQ(NO_ERROR, error.code_);
98 }
99 
TEST_F(UiDriverTest,retrieveWidget)100 TEST_F(UiDriverTest, retrieveWidget)
101 {
102     std::string nodeJson = R"(
103         {
104             "attributes":{
105                 "windowId":"12",
106 				"bundleName":"test1",
107                 "componentType":"List",
108                 "accessibilityId":"1",
109                 "content":"Text List",
110                 "rectInScreen":"30,60,10,120"
111             },
112             "children":[
113                 {
114                     "attributes":{
115                     "windowId":"12",
116                     "bundleName":"test1",
117                     "componentType":"Text",
118                     "accessibilityId":"100",
119                     "content":"USB",
120                     "rectInScreen":"30,60,10,20"
121                     },
122                     "children":[]
123                 }
124             ]
125         }
126     )";
127 
128     std::vector<MockAccessibilityElementInfo> eles =
129         MockElementNodeIterator::ConstructIteratorByJson(nodeJson)->elementInfoLists_;
130 
131     Window w1{12};
132     w1.windowLayer_ = 2;
133     w1.bounds_ = Rect{0, 100, 0, 120};
134 
135     controller_->AddWindowsAndNode(w1, eles);
136 
137     auto error = ApiCallErr(NO_ERROR);
138     auto selector = WidgetSelector();
139     auto matcher = WidgetMatchModel(UiAttr::TEXT, "USB", EQ);
140     selector.AddMatcher(matcher);
141     vector<unique_ptr<Widget>> widgets;
142     selector.SetWantMulti(false);
143     driver_->FindWidgets(selector, widgets, error, true);
144 
145     ASSERT_EQ(1, widgets.size());
146 
147     // mock another dom on which the target widget is missing, and perform click
148 
149     std::vector<MockAccessibilityElementInfo> eles_ =
150         MockElementNodeIterator::ConstructIteratorByJson(nodeJson)->elementInfoLists_;
151     controller_->AddWindowsAndNode(w1, eles_);
152     error = ApiCallErr(NO_ERROR);
153     auto ret = driver_->RetrieveWidget(*widgets.at(0), error, true);
154 
155     // retrieve widget failed should be marked as exception
156     ASSERT_EQ(NO_ERROR, error.code_);
157     ASSERT_TRUE(ret->GetAttr(UiAttr::TEXT) == "USB");
158 }
159 
TEST_F(UiDriverTest,retrieveWidgetFailure)160 TEST_F(UiDriverTest, retrieveWidgetFailure)
161 {
162     std::string beforeNodeJson = R"(
163         {
164             "attributes":{
165                 "windowId":"12",
166 				"bundleName":"test1",
167                 "componentType":"List",
168                 "accessibilityId":"1",
169                 "content":"Text List",
170                 "rectInScreen":"30,60,10,120"
171             },
172             "children":[
173                 {
174                     "attributes":{
175                     "windowId":"12",
176                     "bundleName":"test1",
177                     "componentType":"Text",
178                     "accessibilityId":"100",
179                     "content":"USB",
180                     "rectInScreen":"30,60,10,20"
181                     },
182                     "children":[]
183                 }
184             ]
185         }
186     )";
187 
188     std::vector<MockAccessibilityElementInfo> eles =
189         MockElementNodeIterator::ConstructIteratorByJson(beforeNodeJson)->elementInfoLists_;
190 
191     Window w1{12};
192     w1.windowLayer_ = 2;
193     w1.bounds_ = Rect{0, 100, 0, 120};
194 
195     controller_->AddWindowsAndNode(w1, eles);
196 
197     auto error = ApiCallErr(NO_ERROR);
198     auto selector = WidgetSelector();
199     auto matcher = WidgetMatchModel(UiAttr::TEXT, "USB", EQ);
200     selector.AddMatcher(matcher);
201     vector<unique_ptr<Widget>> widgets;
202     selector.SetWantMulti(false);
203     driver_->FindWidgets(selector, widgets, error, true);
204 
205     ASSERT_EQ(1, widgets.size());
206 
207     // mock another dom on which the target widget is missing, and perform click
208     std::string afterNodeJson = R"(
209         {
210             "attributes":{
211                 "windowId":"12",
212 				"bundleName":"test1",
213                 "componentType":"List",
214                 "accessibilityId":"1",
215                 "content":"Text List",
216                 "rectInScreen":"30,60,10,120"
217             },
218             "children":[
219                 {
220                     "attributes":{
221                     "windowId":"12",
222                     "bundleName":"test1",
223                     "componentType":"Text",
224                     "accessibilityId":"101",
225                     "content":"USB",
226                     "rectInScreen":"30,60,10,20"
227                     },
228                     "children":[]
229                 }
230             ]
231         }
232     )";
233 
234     std::vector<MockAccessibilityElementInfo> eles_ =
235         MockElementNodeIterator::ConstructIteratorByJson(afterNodeJson)->elementInfoLists_;
236 
237     controller_->RemoveWindowsAndNode(w1);
238     controller_->AddWindowsAndNode(w1, eles_);
239     error = ApiCallErr(NO_ERROR);
240     driver_->RetrieveWidget(*widgets.at(0), error, true);
241 
242     // retrieve widget failed should be marked as exception
243     ASSERT_EQ(ERR_COMPONENT_LOST, error.code_);
244     ASSERT_TRUE(error.message_.find(selector.Describe()) != string::npos)
245         << "Error message should contains the widget selection description";
246 }
247 
TEST_F(UiDriverTest,FindWindowByBundleName)248 TEST_F(UiDriverTest, FindWindowByBundleName)
249 {
250     std::string window1NodeJson = R"(
251         {
252             "attributes":{
253                 "windowId":"12",
254 				"bundleName":"test12",
255                 "componentType":"List",
256                 "accessibilityId":"1",
257                 "content":"Text List",
258                 "rectInScreen":"30,60,10,120"
259             },
260             "children":[]
261         }
262     )";
263 
264     std::vector<MockAccessibilityElementInfo> eles =
265         MockElementNodeIterator::ConstructIteratorByJson(window1NodeJson)->elementInfoLists_;
266 
267     Window w1{12};
268     w1.windowLayer_ = 2;
269     w1.bounds_ = Rect{0, 100, 0, 120};
270     w1.bundleName_ = "test12";
271     controller_->AddWindowsAndNode(w1, eles);
272     std::string window2NodeJson = R"(
273         {
274             "attributes":{
275                 "windowId":"123",
276 				"bundleName":"test123",
277                 "componentType":"List",
278                 "accessibilityId":"1",
279                 "content":"Text List",
280                 "rectInScreen":"30,60,10,120"
281             },
282             "children":[]
283         }
284     )";
285 
286     std::vector<MockAccessibilityElementInfo> eles_2 =
287         MockElementNodeIterator::ConstructIteratorByJson(window2NodeJson)->elementInfoLists_;
288 
289     Window w2{123};
290     w2.windowLayer_ = 4;
291     w2.bounds_ = Rect{0, 100, 0, 120};
292     w2.bundleName_ = "test123";
293     controller_->AddWindowsAndNode(w2, eles_2);
294 
295     auto error = ApiCallErr(NO_ERROR);
296 
297     json filterBundle;
298     filterBundle["bundleName"] = "test12";
299     auto windowMatcher = [&filterBundle](const Window &window) -> bool {
300         bool match = true;
301         match = match && window.bundleName_ == filterBundle["bundleName"].get<string>();
302         return match;
303     };
304     auto winPtr = driver_->FindWindow(windowMatcher, error);
305 
306     ASSERT_TRUE(winPtr != nullptr);
307     ASSERT_EQ(winPtr->id_, 12);
308 
309     json filterBundleNotFind;
310     filterBundleNotFind["bundleName"] = "test12456";
311     auto windowMatcher2 = [&filterBundleNotFind](const Window &window) -> bool {
312         bool match = true;
313         match = match && window.bundleName_ == filterBundleNotFind["bundleName"].get<string>();
314         return match;
315     };
316     auto winPtrNull = driver_->FindWindow(windowMatcher2, error);
317     ASSERT_TRUE(winPtrNull == nullptr);
318 }
319 
TEST_F(UiDriverTest,FindWindowByActived)320 TEST_F(UiDriverTest, FindWindowByActived)
321 {
322     std::string window1NodeJson = R"(
323         {
324             "attributes":{
325                 "windowId":"12",
326 				"bundleName":"test12",
327                 "componentType":"List",
328                 "accessibilityId":"1",
329                 "content":"Text List",
330                 "rectInScreen":"30,60,10,120"
331             },
332             "children":[]
333         }
334     )";
335 
336     std::vector<MockAccessibilityElementInfo> eles =
337         MockElementNodeIterator::ConstructIteratorByJson(window1NodeJson)->elementInfoLists_;
338 
339     Window w1{12};
340     w1.windowLayer_ = 2;
341     w1.actived_ = false;
342     w1.bounds_ = Rect{0, 100, 0, 120};
343     w1.bundleName_ = "test12";
344     controller_->AddWindowsAndNode(w1, eles);
345     std::string window2NodeJson = R"(
346         {
347             "attributes":{
348                 "windowId":"123",
349 				"bundleName":"test123",
350                 "componentType":"List",
351                 "accessibilityId":"1",
352                 "content":"Text List",
353                 "rectInScreen":"30,60,10,120"
354             },
355             "children":[]
356         }
357     )";
358 
359     std::vector<MockAccessibilityElementInfo> eles_2 =
360         MockElementNodeIterator::ConstructIteratorByJson(window2NodeJson)->elementInfoLists_;
361 
362     Window w2{123};
363     w2.windowLayer_ = 4;
364     w2.actived_ = true;
365     w2.bounds_ = Rect{0, 100, 0, 120};
366     w2.bundleName_ = "test123";
367     controller_->AddWindowsAndNode(w2, eles_2);
368 
369     auto error = ApiCallErr(NO_ERROR);
370 
371     json filterActive;
372     filterActive["actived"] = true;
373 
374     auto windowMatcher = [&filterActive](const Window &window) -> bool {
375         bool match = true;
376         match = match && window.actived_ == filterActive["actived"].get<bool>();
377 
378         return match;
379     };
380     auto winPtr = driver_->FindWindow(windowMatcher, error);
381 
382     ASSERT_TRUE(winPtr != nullptr);
383     ASSERT_EQ(winPtr->id_, 123);
384 }
385 
TEST_F(UiDriverTest,DumpUI)386 TEST_F(UiDriverTest, DumpUI)
387 {
388     std::string window2NodeJson = R"(
389         {
390             "attributes":{
391                 "windowId":"123",
392 				"bundleName":"test123",
393                 "componentType":"List",
394                 "accessibilityId":"1",
395                 "content":"List",
396                 "rectInScreen":"0,200,100,200"
397             },
398             "children":[
399                 {
400                     "attributes":{
401                         "windowId":"123",
402                         "bundleName":"test123",
403                         "componentType":"Text",
404                         "accessibilityId":"2",
405                         "content":"Text List",
406                         "rectInScreen":"0,200,100,200"
407                     },
408                     "children":[]
409                 }
410             ]
411         }
412     )";
413     std::vector<MockAccessibilityElementInfo> eles_2 =
414         MockElementNodeIterator::ConstructIteratorByJson(window2NodeJson)->elementInfoLists_;
415     Window w2{123};
416     w2.windowLayer_ = 4;
417     w2.actived_ = true;
418     w2.bounds_ = Rect{0, 200, 100, 200};
419     w2.bundleName_ = "test123";
420     controller_->AddWindowsAndNode(w2, eles_2);
421     std::string window1NodeJson = R"(
422         {
423             "attributes":{
424                 "windowId":"12",
425 				"bundleName":"test12",
426                 "componentType":"List",
427                 "accessibilityId":"4",
428                 "content":"Text List",
429                 "rectInScreen":"30,60,10,120"
430             },
431             "children":[
432                 {
433                     "attributes":{
434                         "windowId":"12",
435                         "bundleName":"test12",
436                         "componentType":"Text",
437                         "accessibilityId":"6",
438                         "content":"Text Test",
439                         "rectInScreen":"30,60,10,120"
440                     },
441                     "children":[]
442                 }
443             ]
444         }
445     )";
446     std::vector<MockAccessibilityElementInfo> eles =
447         MockElementNodeIterator::ConstructIteratorByJson(window1NodeJson)->elementInfoLists_;
448     Window w1{12};
449     w1.windowLayer_ = 2;
450     w1.invisibleBoundsVec_.emplace_back(w2.bounds_);
451     w1.actived_ = false;
452     w1.bounds_ = Rect{0, 100, 0, 120};
453     w1.bundleName_ = "test12";
454     controller_->AddWindowsAndNode(w1, eles);
455     auto error = ApiCallErr(NO_ERROR);
456     nlohmann::json out;
457     DumpOption option;
458     driver_->DumpUiHierarchy(out, option, error);
459     ASSERT_EQ(out["children"].size(), 2);
460     auto window1Json = out["children"][0];
461     ASSERT_EQ(window1Json["attributes"]["accessibilityId"], "1");
462     ASSERT_EQ(window1Json["attributes"]["text"], "List");
463     ASSERT_EQ(window1Json["attributes"]["bundleName"], "test123");
464     ASSERT_EQ(window1Json["children"].size(), 1);
465     ASSERT_EQ(window1Json["children"][0]["attributes"]["accessibilityId"], "2");
466     auto window2Json = out["children"][1];
467     ASSERT_EQ(window2Json["attributes"]["accessibilityId"], "4");
468     ASSERT_EQ(window2Json["attributes"]["type"], "List");
469     ASSERT_EQ(window2Json["attributes"]["bundleName"], "test12");
470     ASSERT_EQ(window2Json["attributes"]["text"], "Text List");
471     ASSERT_EQ(window2Json["attributes"]["origBounds"], "[30,10][60,120]");
472     ASSERT_EQ(window2Json["attributes"]["bounds"], "[30,10][60,100]");
473     ASSERT_EQ(window2Json["children"].size(), 1);
474     ASSERT_EQ(window2Json["children"][0]["attributes"]["accessibilityId"], "6");
475     ASSERT_EQ(window2Json["children"][0]["attributes"]["text"], "Text Test");
476     ASSERT_EQ(window2Json["children"][0]["attributes"]["origBounds"], "[30,10][60,120]");
477     ASSERT_EQ(window2Json["children"][0]["attributes"]["bounds"], "[30,10][60,100]");
478 }
479 
TEST_F(UiDriverTest,DumpUI_I)480 TEST_F(UiDriverTest, DumpUI_I)
481 {
482     std::string window2NodeJson = R"(
483         {
484             "attributes":{
485                 "windowId":"123",
486 				"bundleName":"test123",
487                 "componentType":"List",
488                 "accessibilityId":"1",
489                 "content":"List",
490                 "rectInScreen":"0,200,100,200"
491             },
492             "children":[
493                 {
494                     "attributes":{
495                         "windowId":"123",
496                         "bundleName":"test123",
497                         "componentType":"Text",
498                         "accessibilityId":"2",
499                         "content":"Text List",
500                         "rectInScreen":"0,200,100,200"
501                     },
502                     "children":[]
503                 }
504             ]
505         }
506     )";
507     std::vector<MockAccessibilityElementInfo> eles_2 =
508         MockElementNodeIterator::ConstructIteratorByJson(window2NodeJson)->elementInfoLists_;
509     Window w2{123};
510     w2.windowLayer_ = 4;
511     w2.actived_ = true;
512     w2.bounds_ = Rect{0, 200, 100, 200};
513     w2.bundleName_ = "test123";
514     controller_->AddWindowsAndNode(w2, eles_2);
515     std::string window1NodeJson = R"(
516         {
517             "attributes":{
518                 "windowId":"12",
519 				"bundleName":"test12",
520                 "componentType":"List",
521                 "accessibilityId":"4",
522                 "content":"Text List",
523                 "rectInScreen":"30,60,10,120"
524             },
525             "children":[
526                 {
527                     "attributes":{
528                         "windowId":"12",
529                         "bundleName":"test12",
530                         "componentType":"Text",
531                         "accessibilityId":"6",
532                         "content":"Text Test",
533                         "rectInScreen":"30,60,10,120"
534                     },
535                     "children":[]
536                 }
537             ]
538         }
539     )";
540     std::vector<MockAccessibilityElementInfo> eles =
541         MockElementNodeIterator::ConstructIteratorByJson(window1NodeJson)->elementInfoLists_;
542     Window w1{12};
543     w1.windowLayer_ = 2;
544     w1.invisibleBoundsVec_.emplace_back(w2.bounds_);
545     w1.actived_ = false;
546     w1.bounds_ = Rect{0, 100, 0, 120};
547     w1.bundleName_ = "test12";
548     controller_->AddWindowsAndNode(w1, eles);
549     auto error = ApiCallErr(NO_ERROR);
550     nlohmann::json out;
551     DumpOption option;
552     option.listWindows_ = true;
553     driver_->DumpUiHierarchy(out, option, error);
554     ASSERT_EQ(out.size(), 2);
555     auto window1Json = out[0];
556     ASSERT_EQ(window1Json["attributes"]["accessibilityId"], "1");
557     ASSERT_EQ(window1Json["attributes"]["text"], "List");
558     ASSERT_EQ(window1Json["attributes"]["bundleName"], "test123");
559     ASSERT_EQ(window1Json["children"].size(), 1);
560     ASSERT_EQ(window1Json["children"][0]["attributes"]["accessibilityId"], "2");
561     auto window2Json = out[1];
562     ASSERT_EQ(window2Json["attributes"]["accessibilityId"], "4");
563     ASSERT_EQ(window2Json["attributes"]["type"], "List");
564     ASSERT_EQ(window2Json["attributes"]["bundleName"], "test12");
565     ASSERT_EQ(window2Json["attributes"]["text"], "Text List");
566     ASSERT_EQ(window2Json["attributes"]["origBounds"], "[30,10][60,120]");
567     ASSERT_EQ(window2Json["attributes"]["bounds"], "[30,10][60,120]");
568     ASSERT_EQ(window2Json["children"].size(), 1);
569     ASSERT_EQ(window2Json["children"][0]["attributes"]["accessibilityId"], "6");
570     ASSERT_EQ(window2Json["children"][0]["attributes"]["text"], "Text Test");
571     ASSERT_EQ(window2Json["children"][0]["attributes"]["origBounds"], "[30,10][60,120]");
572     ASSERT_EQ(window2Json["children"][0]["attributes"]["bounds"], "[30,10][60,120]");
573 }
574 
575 class WindowCacheCompareGreater {
576 public:
operator ()(const WindowCacheModel & w1,const WindowCacheModel & w2)577     bool operator()(const WindowCacheModel &w1, const WindowCacheModel &w2)
578     {
579         if (w1.window_.actived_) {
580             return true;
581         }
582         if (w2.window_.actived_) {
583             return false;
584         }
585         if (w1.window_.focused_) {
586             return true;
587         }
588         if (w2.window_.focused_) {
589             return false;
590         }
591         return w1.window_.windowLayer_ > w2.window_.windowLayer_;
592     }
593 };
594 
TEST_F(UiDriverTest,SORT_WINDOW)595 TEST_F(UiDriverTest, SORT_WINDOW)
596 {
597     Window w1{1};
598     w1.actived_ = false;
599     w1.focused_ = false;
600     w1.windowLayer_ = 1;
601     Window w2{2};
602     w2.actived_ = false;
603     w2.focused_ = false;
604     w2.windowLayer_ = 2;
605     Window w3{3};
606     w3.actived_ = true;
607     w3.focused_ = true;
608     w3.windowLayer_ = 3;
609     Window w4{4};
610     w4.actived_ = false;
611     w4.focused_ = false;
612     w4.windowLayer_ = 4;
613     Window w5{5};
614     w5.actived_ = false;
615     w5.focused_ = false;
616     w5.windowLayer_ = 5;
617     WindowCacheModel winModel1(w1);
618     WindowCacheModel winModel2(w2);
619     WindowCacheModel winModel3(w3);
620     WindowCacheModel winModel4(w4);
621     WindowCacheModel winModel5(w5);
622     vector<WindowCacheModel> modelVec;
623     modelVec.emplace_back(move(winModel5));
624     modelVec.emplace_back(move(winModel4));
625     modelVec.emplace_back(move(winModel3));
626     modelVec.emplace_back(move(winModel2));
627     modelVec.emplace_back(move(winModel1));
628     std::sort(modelVec.begin(), modelVec.end(), WindowCacheCompareGreater());
629     ASSERT_EQ(modelVec.at(0).window_.id_, 3);
630     ASSERT_EQ(modelVec.at(1).window_.id_, 5);
631     ASSERT_EQ(modelVec.at(2).window_.id_, 4);
632     ASSERT_EQ(modelVec.at(3).window_.id_, 2);
633     ASSERT_EQ(modelVec.at(4).window_.id_, 1);
634 }
635 
TEST_F(UiDriverTest,SORT_WINDOW_ACTIVE)636 TEST_F(UiDriverTest, SORT_WINDOW_ACTIVE)
637 {
638     Window w1{1};
639     w1.actived_ = false;
640     w1.focused_ = false;
641     w1.windowLayer_ = 1;
642     Window w2{2};
643     w2.actived_ = true;
644     w2.focused_ = false;
645     w2.windowLayer_ = 2;
646     Window w3{3};
647     w3.actived_ = false;
648     w3.focused_ = true;
649     w3.windowLayer_ = 3;
650     Window w4{4};
651     w4.actived_ = false;
652     w4.focused_ = false;
653     w4.windowLayer_ = 4;
654     Window w5{5};
655     w5.actived_ = false;
656     w5.focused_ = false;
657     w5.windowLayer_ = 5;
658     WindowCacheModel winModel1{w1};
659     WindowCacheModel winModel2{w2};
660     WindowCacheModel winModel3{w3};
661     WindowCacheModel winModel4{w4};
662     WindowCacheModel winModel5{w5};
663     vector<WindowCacheModel> modelVec;
664     modelVec.emplace_back(move(winModel5));
665     modelVec.emplace_back(move(winModel4));
666     modelVec.emplace_back(move(winModel3));
667     modelVec.emplace_back(move(winModel2));
668     modelVec.emplace_back(move(winModel1));
669     std::sort(modelVec.begin(), modelVec.end(), WindowCacheCompareGreater());
670     ASSERT_EQ(modelVec.at(0).window_.id_, 2);
671     ASSERT_EQ(modelVec.at(1).window_.id_, 3);
672     ASSERT_EQ(modelVec.at(2).window_.id_, 5);
673     ASSERT_EQ(modelVec.at(3).window_.id_, 4);
674     ASSERT_EQ(modelVec.at(4).window_.id_, 1);
675 }