int count1(struct node *p) { if (p == NULL) return(0); else if (p->left == NULL && p->right == NULL) return(1); else return(1 + (count1(p->left) + count1(p->right))); }
void TreeCtrlTestCase::ItemClick() { #if wxUSE_UIACTIONSIMULATOR wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_ACTIVATED); EventCounter count1(m_tree, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK); wxUIActionSimulator sim; wxRect pos; m_tree->GetBoundingRect(m_child1, pos, true); // We move in slightly so we are not on the edge wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4); sim.MouseMove(point); wxYield(); sim.MouseDblClick(); wxYield(); sim.MouseClick(wxMOUSE_BTN_RIGHT); wxYield(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_ACTIVATED)); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK)); #endif // wxUSE_UIACTIONSIMULATOR }
void BookCtrlBaseTestCase::ChangeEvents() { wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); wxBookCtrlBase * const base = GetBase(); base->SetSelection(0); EventCounter count(base, GetChangingEvent()); EventCounter count1(base, GetChangedEvent()); base->SetSelection(1); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent())); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent())); base->ChangeSelection(2); CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(GetChangingEvent())); CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(GetChangedEvent())); base->AdvanceSelection(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent())); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent())); base->AdvanceSelection(false); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent())); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent())); }
void ExternalFiles::convert() { STD1::uint16_t count1( 0 ); for( TableIter itr = table.begin(); itr != table.end(); ++itr, ++count1 ) { itr->second = count1; } }
void ListCtrlTestCase::ColumnClick() { wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); EventCounter count(m_list, wxEVT_COMMAND_LIST_COL_CLICK); EventCounter count1(m_list, wxEVT_COMMAND_LIST_COL_RIGHT_CLICK); m_list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); wxUIActionSimulator sim; sim.MouseMove(m_list->ClientToScreen(wxPoint(4, 4))); wxYield(); sim.MouseClick(); sim.MouseClick(wxMOUSE_BTN_RIGHT); wxYield(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_CLICK)); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)); m_list->ClearAll(); }
void TreeCtrlTestCase::CollapseExpandEvents() { wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); m_tree->CollapseAll(); EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSED); EventCounter count1(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSING); EventCounter count2(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDED); EventCounter count3(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDING); wxUIActionSimulator sim; wxRect pos; m_tree->GetBoundingRect(m_root, pos, true); // We move in slightly so we are not on the edge wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4); sim.MouseMove(point); wxYield(); sim.MouseDblClick(); wxYield(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_EXPANDING)); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_EXPANDED)); sim.MouseDblClick(); wxYield(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_COLLAPSING)); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_COLLAPSED)); }
void ListBaseTestCase::EditLabel() { #if wxUSE_UIACTIONSIMULATOR wxListCtrl* const list = GetList(); list->SetWindowStyleFlag(wxLC_REPORT | wxLC_EDIT_LABELS); list->InsertColumn(0, "Column 0"); list->InsertItem(0, "Item 0"); list->InsertItem(1, "Item 1"); wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); EventCounter count(list, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT); EventCounter count1(list, wxEVT_COMMAND_LIST_END_LABEL_EDIT); wxUIActionSimulator sim; list->EditLabel(0); sim.Text("sometext"); sim.Char(WXK_RETURN); wxYield(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_END_LABEL_EDIT)); #endif }
// Returns the count of ways we can sum S[0...m-1] coins to get sum n int count1(int S[], int m, int n) { // If n is 0 then there is 1 solution (do not include any coin) if (n == 0) return 1; // If n is less than 0 then no solution exists if (n < 0) return 0; // If there are no coins and n is greater than 0, then no solution exist if (m <=0 && n >= 1) return 0; // count is sum of solutions (i) including S[m-1] (ii) excluding S[m-1] return count1( S, m - 1, n ) + count1( S, m, n-S[m-1] ); }
int main( int coreid ) { if( coreid == 0 ) { return count0(); } else if( coreid == 1 ) { return count1(); } return 0; }
void count(unsigned long int ip)//十进制与二进制的转换函数 { int array[32]={0}; int res,consult,i=0; res=ip%2; consult=ip/2; while(consult) { ip=consult; array[i++]=res; res=ip%2; consult=ip/2; } count1(&array[0]); printf("."); count1(&array[8]); printf("."); count1(&array[16]); printf("."); count1(&array[24]); }
// Driver program to test above function int main() { MySolution solution; int arr[] = {2, 3, 5, 6}; int m = sizeof(arr)/sizeof(arr[0]); int n = 10; printf("%d\n", solution.count1(arr, m, n)); printf("%d\n", solution.count2(arr, m, n)); printf("%d\n", count1(arr, m, n)); return 0; }
int* BSTRighttoLeftRows(struct node* root) { if (root == NULL) return 0; int n = count1(root); int *array = (int*)malloc(sizeof(int)*n); int h = height1(root); int i, index = 0; for (i = 1; i <= h; i++) printLevel(root, i, array, &index); return array; }
bool IsAnagram(const std::string &s1, const std::string &s2) { if (s1.length() != s2.length()) return false; std::vector<int> count1(26, 0), count2(26, 0); for (int i = 0; i < s1.length(); i++) { count1[s1[i] - 'a']++; count2[s2[i] - 'a']++; } for (int i = 0; i < 26; i++) if (count1[i] != count2[i]) return false; return true; }
List *mergesort(List *head) { int k = count1(head); List *left; List *right; List *tmp1; List *tmp2; if (k > 1) { left = head; right = head; int i = 0; for (; i < k/2 ; i++) { tmp1 = right; right = right->next; } tmp1->next = NULL; left = mergesort(left); right = mergesort(right); } else { left = head; right = NULL; } tmp1 = (List *) malloc (sizeof(List)); tmp2 = tmp1; while (left != NULL && right != NULL) { if (left->value < right->value) { tmp2->next = left; tmp2 = tmp2->next; left = left->next; tmp2->next = NULL; } else { tmp2->next = right; tmp2 = tmp2->next; right = right->next; tmp2->next = NULL; } } if (left != NULL) { tmp2->next = left; } else { tmp2->next = right; } tmp1 = tmp1->next; return tmp1; }
//在main()函数中调用count()函数 main() { int i; //调用count1()10次 cout<<"count1():"<<endl; for (i=1;i<=12;i++) cout<<count1()<<" "; cout<<endl; //调用count2()10次 cout<<"count2():"<<endl; for (i=1;i<=12;i++) cout<<count2()<<" "; cout<<endl; }
TEST(Pointer, SPtr) { static int count = 0; struct counter { counter() { ++count; } ~counter() { --count; } void nop() {} }; struct counter_inherit : counter {}; { util::sptr<counter> count0(new counter); ASSERT_TRUE(count0.not_nul()); ASSERT_TRUE((*count0).not_nul()); ASSERT_EQ(1, count); util::sref<counter> refcount0 = *count0; util::sptr<counter> count1(std::move(count0)); ASSERT_EQ(1, count); util::sref<counter> refcount1 = *count1; ASSERT_EQ(refcount0.id().str(), refcount1.id().str()); ASSERT_EQ(refcount0.id().str(), count1.id().str()); ASSERT_TRUE(count0.nul()); ASSERT_TRUE((*count0).nul()); util::sptr<counter_inherit> count2(new counter_inherit); count1 = std::move(count2); ASSERT_EQ(1, count); util::sptr<counter_inherit> count3(new counter_inherit); ASSERT_EQ(2, count); util::sptr<counter> count4(std::move(count3)); count4->nop(); } ASSERT_EQ(0, count); }
void count_if1(CL_FORM *base) { GEN_HEAPVAR(ARG(0), ARG(6)); LOAD_NIL(ARG(6)); COPY(ARG(1), ARG(7)); COPY(ARG(2), ARG(8)); { GEN_CLOSURE(array, ARG(9), 4, Z27_lambda, 2); COPY(ARG(0), &array[3]); LOAD_CLOSURE(array, ARG(9)); } COPY(ARG(9), ARG(9)); LOAD_NIL(ARG(10)); COPY(ARG(3), ARG(11)); COPY(ARG(4), ARG(12)); COPY(ARG(5), ARG(13)); count1(ARG(6)); COPY(ARG(6), ARG(0)); }
void ScopeGuardTestCase::BlockExitObj() { Counter count0(1), count1(2), count2(3); { wxON_BLOCK_EXIT_OBJ0(count0, Counter::Zero); wxON_BLOCK_EXIT_OBJ1(count1, Counter::Set, 17); wxON_BLOCK_EXIT_OBJ2(count2, Counter::Sum, 2, 3); CPPUNIT_ASSERT_EQUAL( 1, count0.GetCount() ); CPPUNIT_ASSERT_EQUAL( 2, count1.GetCount() ); CPPUNIT_ASSERT_EQUAL( 3, count2.GetCount() ); } CPPUNIT_ASSERT_EQUAL( 0, count0.GetCount() ); CPPUNIT_ASSERT_EQUAL( 17, count1.GetCount() ); CPPUNIT_ASSERT_EQUAL( 5, count2.GetCount() ); }
void ListBaseTestCase::DeleteItems() { #ifndef __WXOSX__ wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); wxListCtrl* const list = GetList(); EventCounter count(list, wxEVT_COMMAND_LIST_DELETE_ITEM); EventCounter count1(list, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS); list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); list->InsertItem(0, "Item 0"); list->InsertItem(1, "Item 1"); list->InsertItem(2, "Item 1"); list->DeleteItem(0); list->DeleteItem(0); list->DeleteAllItems(); //Add some new items to tests ClearAll with list->InsertColumn(0, "Column 0"); list->InsertItem(0, "Item 0"); list->InsertItem(1, "Item 1"); //Check that ClearAll actually sends a DELETE_ALL_ITEMS event list->ClearAll(); //ClearAll and DeleteAllItems shouldn't send an event if there was nothing //to clear list->ClearAll(); list->DeleteAllItems(); CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_LIST_DELETE_ITEM)); CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)); #endif }
void TextCtrlTestCase::MaxLength() { #if wxUSE_UIACTIONSIMULATOR wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); EventCounter count(m_text, wxEVT_COMMAND_TEXT_UPDATED); EventCounter count1(m_text, wxEVT_COMMAND_TEXT_MAXLEN); m_text->SetFocus(); m_text->SetMaxLength(10); wxUIActionSimulator sim; sim.Text("abcdef"); wxYield(); CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN)); sim.Text("ghij"); wxYield(); CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN)); CPPUNIT_ASSERT_EQUAL(10, frame->GetEventCount(wxEVT_COMMAND_TEXT_UPDATED)); sim.Text("k"); wxYield(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN)); CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_UPDATED)); m_text->SetMaxLength(0); sim.Text("k"); wxYield(); CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN)); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TEXT_UPDATED)); #endif }
void Fcount(CL_FORM *base, int nargs) { BOOL supl_flags[6]; static CL_FORM * keylist[] = { SYMBOL(Slisp, 284), /* FROM-END */ SYMBOL(Slisp, 272), /* TEST */ SYMBOL(Slisp, 553), /* TEST-NOT */ SYMBOL(Slisp, 229), /* START */ SYMBOL(Slisp, 230), /* END */ SYMBOL(Slisp, 207), /* KEY */ }; keysort(ARG(2), nargs - 2, 6, keylist, supl_flags, FALSE); if(NOT(supl_flags[0])) { LOAD_NIL(ARG(2)); } if(NOT(supl_flags[1])) { LOAD_NIL(ARG(3)); } if(NOT(supl_flags[2])) { LOAD_NIL(ARG(4)); } if(NOT(supl_flags[3])) { LOAD_SMALLFIXNUM(0, ARG(5)); } if(NOT(supl_flags[4])) { COPY(SYMVAL(Slisp, 0), ARG(6)); /* MOST-POSITIVE-FIXNUM */ } if(NOT(supl_flags[5])) { LOAD_NIL(ARG(7)); } count1(ARG(0)); }
bool IsScramble1(const std::string &s1, const std::string &s2) { if (s1 == s2) return true; if (s1.length() != s2.length()) return false; std::vector<int> count1(26, 0), count2(26, 0); for (int i = 0; i < s1.length(); i++) { count1[s1[i] - 'a']++; count2[s2[i] - 'a']++; } for (int i = 0; i < 26; i++) if (count1[i] != count2[i]) return false; for (int i = 1; i < s1.length(); i++) { if (IsScramble1(s1.substr(0, i), s2.substr(0, i)) && IsScramble1(s1.substr(i), s2.substr(i))) return true; if (IsScramble1(s1.substr(0, i), s2.substr(s1.length() - i)) && IsScramble1(s1.substr(i), s2.substr(0, s1.length() - i))) return true; } return false; }
void TreeCtrlTestCase::LabelEdit() { wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); EventCounter count(m_tree, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT); EventCounter count1(m_tree, wxEVT_COMMAND_TREE_END_LABEL_EDIT); wxUIActionSimulator sim; m_tree->SetFocusedItem(m_tree->GetRootItem()); m_tree->EditLabel(m_tree->GetRootItem()); sim.Text("newroottext"); wxYield(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); sim.Char(WXK_RETURN); wxYield(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); }
void ListCtrlTestCase::ColumnDrag() { wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); EventCounter count(m_list, wxEVT_COMMAND_LIST_COL_BEGIN_DRAG); EventCounter count1(m_list, wxEVT_COMMAND_LIST_COL_DRAGGING); EventCounter count2(m_list, wxEVT_COMMAND_LIST_COL_END_DRAG); m_list->InsertColumn(0, "Column 0"); m_list->InsertColumn(1, "Column 1"); m_list->InsertColumn(2, "Column 2"); m_list->Update(); m_list->SetFocus(); wxUIActionSimulator sim; wxPoint pt = m_list->ClientToScreen(wxPoint(m_list->GetColumnWidth(0), 5)); sim.MouseMove(pt); wxYield(); sim.MouseDown(); wxYield(); sim.MouseMove(pt.x + 50, pt.y); wxYield(); sim.MouseUp(); wxYield(); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)); CPPUNIT_ASSERT(frame->GetEventCount(wxEVT_COMMAND_LIST_COL_DRAGGING) > 0); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_END_DRAG)); m_list->ClearAll(); }
void TreeCtrlTestCase::SelectionChange() { wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); m_tree->ExpandAll(); m_tree->UnselectAll(); EventCounter count(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGED); EventCounter count1(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGING); wxUIActionSimulator sim; wxRect poschild1, poschild2; m_tree->GetBoundingRect(m_child1, poschild1, true); m_tree->GetBoundingRect(m_child1, poschild2, true); // We move in slightly so we are not on the edge wxPoint point1 = m_tree->ClientToScreen(poschild1.GetPosition()) + wxPoint(4, 4); wxPoint point2 = m_tree->ClientToScreen(poschild2.GetPosition()) + wxPoint(4, 4); sim.MouseMove(point1); wxYield(); sim.MouseClick(); wxYield(); sim.MouseMove(point2); wxYield(); sim.MouseClick(); wxYield(); CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_TREE_SEL_CHANGED)); CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_TREE_SEL_CHANGING)); }
int main() { scanf("%d%d", &n, &m); for(int i = 1; i <= n; ++i) scanf("%d", a + i); for(sqn = 1; sqn * sqn < n; ++sqn); sqn = std::max(sqn, (n - 1) / 200 + 1); for(int i = 1, j = 1; i <= n; i += sqn, ++j) { int iLim = std::min(i + sqn - 1, n); fir[j] = i; for(int k = i; k <= iLim; ++k) pos[k] = j; } blk = pos[n]; fir[blk + 1] = n + 1; for(int i = 1; i <= blk; ++i) { memset(b[i] + 1, 0, blk * sizeof(int)); memset(c[i] + 1, 0, n * sizeof(int)); } for(int i = 1; i <= n; ++i) { int x = pos[i], v = a[i], y = pos[v]; ++b[x][y]; ++c[x][v]; p[1][i] = q[1][i] = i; } for(int i = 2; i <= blk; ++i) { for(int j = 1; j <= blk; ++j) b[i][j] += b[i - 1][j]; for(int j = 1; j <= n; ++j) c[i][j] += c[i - 1][j]; memcpy(p[i] + 1, p[1] + 1, n * sizeof(int)); memcpy(q[i] + 1, q[1] + 1, n * sizeof(int)); } while(m--) { int typ, L, R, A, B, pL, pR; scanf("%d%d%d%d", &typ, &L, &R, &A); pL = pos[L]; pR = pos[R]; if(typ == 1) { scanf("%d", &B); if(A == B) continue; int pA = pos[A], pB = pos[B]; if(pL == pR) { int dt = modify(L, R, pL, A, B); if(dt) for(int i = pL; i <= blk; ++i) { b[i][pA] -= dt; b[i][pB] += dt; c[i][A] -= dt; c[i][B] += dt; } } else { int dt = 0; for(int i = pL; i <= blk; ++i) { if(dt) { b[i][pA] -= dt; b[i][pB] += dt; c[i][A] -= dt; c[i][B] += dt; } if(i > pR) continue; int res = modify(std::max(L, fir[i]), std::min(R, fir[i + 1] - 1), i, A, B); if(res) { b[i][pA] -= res; b[i][pB] += res; c[i][A] -= res; c[i][B] += res; dt += res; } } } } else { int y, ans; memset(cnt + 1, 0, blk * sizeof(int)); if(fir[pL] < L || R < fir[pR + 1] - 1) { if(pL == pR) { count1(L, R, pL); ++pL; } else { if(fir[pL] < L) { count1(L, fir[pL + 1] - 1, pL); ++pL; } if(R < fir[pR + 1] - 1) { count1(fir[pR], R, pR); --pR; } } } for(y = 1; y <= blk; ++y) { int ctr = cnt[y] + b[pR][y] - b[pL - 1][y]; if(A <= ctr) break; A -= ctr; } pL = pos[L]; pR = pos[R]; _cnt = cnt - fir[y] + 1; memset(cnt + 1, 0, sqn * sizeof(int)); if(fir[pL] < L || R < fir[pR + 1] - 1) { if(pL == pR) { count2(L, R, pL, y); ++pL; } else { if(fir[pL] < L) { count2(L, fir[pL + 1] - 1, pL, y); ++pL; } if(R < fir[pR + 1] - 1) { count2(fir[pR], R, pR, y); --pR; } } } for(ans = fir[y]; ans < fir[y + 1]; ++ans) { int ctr = _cnt[ans] + c[pR][ans] - c[pL - 1][ans]; if(A <= ctr) break; A -= ctr; } printf("%d\n", ans); } } return 0; }
void ListBaseTestCase::ItemClick() { // FIXME: This test fail under wxGTK because we get 3 FOCUSED events and // 2 SELECTED ones instead of the one of each we expect for some // reason, this needs to be debugged as it may indicate a bug in the // generic wxListCtrl implementation. #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) // FIXME: This test fails on MSW buildbot slaves although works fine on // development machine, no idea why. It seems to be a problem with // wxUIActionSimulator rather the wxListCtrl control itself however. if ( wxGetUserId().Lower().Matches("buildslave*") ) return; wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); wxListCtrl* const list = GetList(); list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); list->InsertItem(0, "Item 0"); list->SetItem(0, 1, "first column"); list->SetItem(0, 2, "second column"); EventCounter count(list, wxEVT_COMMAND_LIST_ITEM_SELECTED); EventCounter count1(list, wxEVT_COMMAND_LIST_ITEM_FOCUSED); EventCounter count2(list, wxEVT_COMMAND_LIST_ITEM_ACTIVATED); EventCounter count3(list, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK); wxUIActionSimulator sim; wxRect pos; list->GetItemRect(0, pos); //We move in slightly so we are not on the edge wxPoint point = list->ClientToScreen(pos.GetPosition()) + wxPoint(2, 2); sim.MouseMove(point); wxYield(); sim.MouseClick(); wxYield(); sim.MouseDblClick(); wxYield(); sim.MouseClick(wxMOUSE_BTN_RIGHT); wxYield(); // when the first item was selected the focus changes to it, but not // on subsequent clicks CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_FOCUSED)); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_SELECTED)); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)); CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)); //tidy up when we are finished list->ClearAll(); #endif // wxUSE_UIACTIONSIMULATOR }